1.0.2 • Published 3 years ago

node-encryption v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

node-encryption

This package will simplify the process of encrypting and decrypting data for your application based on the aes-256-gcm algorithm.

$ 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 decyptBuffer = decrypt(encryptBuffer, encryptionKey);

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

How to encrypt a file

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

const encryptionKey = 'mysecretkey1337';

const encrypted = encrypt(image, encryptionKey);

const decrytedImageBuffer = decrypt(encrypted, encryptionKey);

License

MIT - see LICENSE