Created
July 28, 2017 18:08
-
-
Save dannycoates/a25491661ceb7645c30be234c96c3de7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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