Secure-keys

secure-keys

Encrypts and Decrypts object keys.

This module uses node's inbuilt crypto to encrypt and decrypt object keys and the code was yanked out of work by @indexzero for nconf

Get it: npm install --save secure-keys

Sample usage:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const secureKeys = require("secure-keys")

const sk = new secureKeys({secret: 'NOTW'});
const enCat = sk.encrypt({cat: 'meow'})
const deCat = sk.decrypt(enCat);

console.log('encrypted object:', enCat);

console.log('decrypted object:', deCat);

/*
encrypted object: { cat: { alg: 'aes-256-ctr', value: '3f1ead878c36' } }

decrypted object: { cat: 'meow' }
*/
1
2
3
4
5
var sec = new SecK({
  secret: 'BEGIN RSA', // Text of key used for encrypting/decrypting 
  format: JSON, // optional (defaults to JSON): An object with `stringify` and `parse` methods 
  alg: 'aes-256-ctr' //optional (this is default) Algorithm to use for encrypt/decrypt 
});

GIF FTW!

Suggest a module

Comments