symmetric-encrypt
Password-based encryption and decryption in Node.js
- Encrypt and decrypt data using a password
- AES-GCM for fast and secure symmetric encryption
- Argon2Id for high work-factor and ASIC-resistant key derivation, using Libsodium compiled to WASM
- Portable function parameters for encryption and key derivation, encoded in the output for backwards compatibility
- Designed to use with a separate persistence layer
Instal
npm install symmetric-encrypt
Requires Node.js 10+.
Usage
const generateEncryptionKey decrypt = { /** * The key only needs to be generated once per session, so * `encrypt` can be called multiple times with different messages */ const encrypt = await const encryptedConfig = await /** * For instance, `encryptedConfig` could be encoded * in JSON and written to a file. Later, the file could * be opened and parsed as JSON, to be decrypted. */ const message = await console // -> "this is a message"}