Hybrid encryption powered by RSA and AES
npm install zest-encryptionSophisticated hybrid encryption leveraging the power of RSA and AES technologies.
js
const zest = require("zest-encryption");
// or (ESM)
import zest from 'zest-encryption';const fs = require("fs");
// Encryption / decryption demo
const key = new zest.EncryptionKey();
key.createKey();
const encryptedMessage = key.encrypt("Hello, World!");
const decryptedMessage = key.decrypt(encryptedMessage);
if (decryptedMessage === "Hello, World!") {
console.log("Encryption and decryption successful!");
}
// Key export / import demo
fs.writeFileSync(".key", key.export());
const importedKey = new zest.EncryptionKey(fs.readFileSync(".key").toString());
// or
const manuallyImportedKey = new zest.EncryptionKey();
manuallyImportedKey.import(fs.readFileSync(".key").toString());
`Notes
- Default Key Generation: A new encryption key is automatically generated whenever a new instance of zest.EncryptionKey is instantiated. This implies that invoking key.createKey() is not mandatory.
- RSA Modulus Length: The default RSA modulus length is 2048 bits. However, this can be customized by invoking the key.createKey()` method.Thanks goes to these wonderful people (emoji key):
David 📖 | mjk134 📓 | VihangaTheTurtle 💻 | ||||
Add your contributions | ||||||
This project follows the all-contributors specification. Contributions of any kind welcome!