Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

node-encryption

sy2x1.5kMIT2.0.1TypeScript support: included

This package will simplify the process of encrypting and decrypting data for your application providing robust AES-256-GCM encryption and decryption utilities for protecting sensitive data.

encrypt, decrypt, encryption, decryption, aes-256-gcm, aes, gcm, security, privacy, gdpr

readme

node-encryption

This package will simplify the process of encrypting and decrypting data for your application providing robust AES-256-GCM encryption and decryption utilities for protecting sensitive data.

$ npm install --save node-encryption

How to use this package

const { encrypt, decrypt } = require('node-encryption');

const text = 'This will be encrypted';
const encryptionKey = 'mysecretkey1337';

const encrypted = encrypt(text, encryptionKey);

const decrypted = decrypt(encrypted, encryptionKey);

console.log(decrypted.toString());
// Output: This will be encrypted

// By using a buffer
const encryptBuffer = encrypt(Buffer.from(text), encryptionKey);

const decryptBuffer = decrypt(encryptBuffer, encryptionKey);

console.log(decryptBuffer.toString());
// Output: This will be encrypted

How to encrypt & decrypt a file

const image = fs.readFileSync('./shyguy.png');

const encryptionKey = 'mysecretkey1337';

const encrypted = encrypt(image, encryptionKey);

const decrytedImageBuffer = decrypt(encrypted, encryptionKey);

Development

$ npm install
$ npm test

License

MIT - see LICENSE