sealbox
v1.10.14
Published
Discreet network traffic encryption with ephemeral keys and end-to-end security
Downloads
6
Maintainers
Readme
sealbox
Secure your network data easily. We encrypt everything so no one can read or mess with it while it travels.
Install
npm install sealboxHow to use (Automatic)
1. Server (Receives data)
const { CipherTransport } = require('sealbox');
// In a real app, generate these once and save them securely!
const ECDH = require('sealbox/src/crypto/primitives/ecdh');
async function startServer() {
const keys = await ECDH.generateKeyPair();
const SERVER_PRIVATE_KEY = keys.privateKey;
const SERVER_PUBLIC_KEY = keys.publicKey;
console.log("Give this Public Key to the client:", SERVER_PUBLIC_KEY);
// When you get a request:
async function onReceive(encryptedData) {
const transport = new CipherTransport();
// Unlocks the data automatically
try {
const opened = await transport.open(encryptedData, SERVER_PRIVATE_KEY);
console.log("Decrypted Message:", JSON.parse(opened.toString()));
} catch (err) {
console.error("Security warning: Data was tampered with!");
}
}
}
startServer();2. Client (Sends data)
const { CipherTransport } = require('sealbox');
// Paste the Server's Public Key here
const SERVER_PUBLIC_KEY = `...`;
async function send() {
const transport = new CipherTransport();
const myData = { password: "super_secret", id: 123 };
// Locks the data automatically using the Server's Public Key
const box = await transport.seal(myData, SERVER_PUBLIC_KEY);
// Send 'box' to your server (e.g., via fetch or axios)
console.log("Ready to send:", box.toJSON());
}
send();Why use this?
It handles all the complex math for you. It ensures:
- Privacy: Only the server can read the data.
- Safety: If someone changes the data, the server rejects it.
- Simplicity: No need to manage session keys manually.
Deep Packet Inspection (DPI) View
If a network administrator or hacker inspects the packet (DPI), they will not see your JSON data. They will only see an opaque, random-looking structure like this:
{
"v": "1",
"k": "04a2...b7c9",
"i": "8f3a...1d4e",
"c": "a1b2c3d4e5...9988776655",
"t": "f1a2...b3c4"
}- v: Version of the protocol.
- k: Ephemeral Public Key (harmless to share).
- i: Initialization Vector (randomness for the cipher).
- c: Ciphertext (Your actual data, fully encrypted).
- t: Auth Tag (Ensures nobody tampered with the data).
License
MIT
