Created
October 29, 2010 15:46
-
-
Save lsm/653787 to your computer and use it in GitHub Desktop.
long string cipher->base64 and decipher
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 c = require('crypto'); | |
// cipher to binary | |
var cipher = c.createCipher('aes192', 'hello'); | |
var en = cipher.update('你好你好你好你好你好dfferfdgwefdv4t5g56euhergy56yhe54wtfgq34tg你好你好你好你好你好你好你好erwgw43etr', 'utf8', 'binary') + cipher.final('binary'); | |
console.log(en); | |
// binary to base64 | |
var buff = new Buffer(en, 'binary'); | |
var base64 = buff.toString('base64'); | |
console.log(base64); | |
// base64 to utf8 (decipher) | |
var decipher = c.createDecipher('aes192', 'hello'); | |
var de = decipher.update(base64, 'base64', 'utf8') + decipher.final('utf8'); | |
console.log(de); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment