npm

npm’s 2019 JavaScript ecosystem survey analysis is now available!Get your copy here »

symmetric-encrypt

1.0.0 • Public • Published

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 } = require('symmetric-encrypt')
 
async function run() {
  /**
   * The key only needs to be generated once per session, so
   * `encrypt` can be called multiple times with different messages
   */
  const encrypt = await generateEncryptionKey('this is a password')
  const encryptedConfig = await encrypt('this is the message')
 
  /**
   * 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 decrypt('this is a password', encryptedConfig)
  console.log(message) // -> "this is a message"
}
 
run().catch(err => console.error(err))

install

npm i symmetric-encrypt

Downloadsweekly downloads

4

version

1.0.0

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability