Created
February 10, 2011 11:25
-
-
Save dekz/820349 to your computer and use it in GitHub Desktop.
weird output of crypto module in node
This file contains hidden or 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 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