Skip to content

Instantly share code, notes, and snippets.

@calvinmetcalf
Created November 28, 2014 17:18
Show Gist options
  • Save calvinmetcalf/2bcb9d7e552a2fbdba08 to your computer and use it in GitHub Desktop.
Save calvinmetcalf/2bcb9d7e552a2fbdba08 to your computer and use it in GitHub Desktop.
var data = new Buffer(64);
data.fill(0);
var key = crypto.randomBytes(16);
var iv1 = new Buffer(16);
iv1.fill(255);
var iv2 = new Buffer('');
var cipher = crypto.createCipheriv('aes-128-ctr', key, iv1);
var decipher = crypto.createDecipheriv('aes-128-ecb', key, iv2);
var out = decipher.update(cipher.update(data));
console.log(out.toString('hex'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment