Skip to content

Instantly share code, notes, and snippets.

@kessler
Created August 17, 2015 23:20
Show Gist options
  • Save kessler/68c2c206b2cec0902ff6 to your computer and use it in GitHub Desktop.
Save kessler/68c2c206b2cec0902ff6 to your computer and use it in GitHub Desktop.
var cipher1 = crypto.createCipheriv('aes-128-ctr', key, iv)
var cipher2 = crypto.createCipheriv('aes-128-ctr', key, iv)
var enc = cipher1.update('123abcd', 'utf8', 'hex')
enc += cipher1.final('hex')
console.log(enc)
var dec = cipher2.update(enc, 'hex', 'utf8')
console.log(dec)
// prints:
// 74bd8f49ca6979
// 123abcd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment