Skip to content

Instantly share code, notes, and snippets.

@dekz
Created February 10, 2011 11:25
Show Gist options
  • Select an option

  • Save dekz/820349 to your computer and use it in GitHub Desktop.

Select an option

Save dekz/820349 to your computer and use it in GitHub Desktop.
weird output of crypto module in node
var fs=require('fs'), c=require('crypto'), assert=require('assert');
var h = c.createHash('SHA256');
h.update('12345');
h.update('54321');
var key=h.digest('base64');
var enc = c.createCipher('AES-128-CBC', key);
var a=enc.update('12345678901234567890', 'utf8', 'base64');
var cipherText = enc.final('base64');
var dec = c.createDecipher('AES-128-CBC', key);
a = dec.update(cipherText, 'base64', 'utf8');
a = dec.final(cipherText, 'utf8');
console.log(a);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment