Skip to content

Instantly share code, notes, and snippets.

@dannycoates
Created July 28, 2017 18:08
Show Gist options
  • Save dannycoates/a25491661ceb7645c30be234c96c3de7 to your computer and use it in GitHub Desktop.
Save dannycoates/a25491661ceb7645c30be234c96c3de7 to your computer and use it in GitHub Desktop.
var ece = require('http_ece');
var crypto = require('crypto');
var base64 = require('base64url');
var parameters = {
key: base64.encode(crypto.randomBytes(16)),
salt: base64.encode(crypto.randomBytes(16))
};
const data = new Buffer('hello, world!', 'utf8');
var encrypted = ece.encrypt(data, parameters);
var decrypted = ece.decrypt(encrypted, parameters);
console.log(decrypted.toString('utf8'))
require('assert').equal(decrypted.compare(data), 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment