node.js - Decrypt cipher text using NodeJs createDecipheriv. What am I doing wrong? -


i have following code should decrypt encrypted text:

var crypto = require('crypto'); var buffer = require('buffer').buffer;  var iv = new buffer('the-iv', 'binary'); //length=16 var key = new buffer('the-secret-key', 'binary');//length=30  var encryptedtext = new buffer('base64-encoded-encrypted-data', 'base64');  var decipher = crypto.createdecipheriv('aes-128-cbc', key, iv); //using aes-128-cbc algorithm decrypted = decipher.update(encryptedtext, "binary", 'utf8'); decrypted += decipher.final('utf8'); 

when execute script node test-main.js, following error:

node-crypto : invalid key length 30  crypto.js:355   this._binding.initiv(cipher, tobuf(key), tobuf(iv));                 ^ error: decipherinitiv error     @ new decipheriv (crypto.js:355:17)     @ object.decipheriv (crypto.js:352:12)     @ object.<anonymous> (path/to/file/test-main.js:9:19)     @ module._compile (module.js:456:26)     @ object.module._extensions..js (module.js:474:10)     @ module.load (module.js:356:32)     @ function.module._load (module.js:312:12)     @ function.module.runmain (module.js:497:10)     @ startup (node.js:119:16)     @ node.js:901:3 

my nodejs version 0.10.15

i not sure doing wrong/missing.

please try using key length of 16. aes-128-cbc uses 128 bit key.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

php - joomla get content in onBeforeCompileHead function -