Déchiffrer AES256 avec node.js renvoie une longueur de bloc finale incorrecte

À l'aide de cette Gist j'ai été en mesure de déchiffrer AES256 dans Node.js 0.8.7. Puis, quand j'ai mis à Node.js 0.10.24, je vois maintenant ce message d'erreur:

TypeError: error:0606506D:enveloppe numérique
routines:EVP_DecryptFinal_ex:mauvais finale de la longueur du bloc
au Decipheriv.Algorithme de chiffrement.finale (crypto.js:292:27)

Voici le déchiffrer le code de la Gist (illustré ici par commodité):

var crypto = require('crypto');

var AESCrypt = {};

AESCrypt.decrypt = function(cryptkey, iv, encryptdata) {
encryptdata = new Buffer(encryptdata, 'base64').toString('binary');

var decipher = crypto.createDecipheriv('aes-256-cbc', cryptkey, iv),
decoded = decipher.update(encryptdata);

decoded += decipher.final();
return decoded;
}

AESCrypt.encrypt = function(cryptkey, iv, cleardata) {
var encipher = crypto.createCipheriv('aes-256-cbc', cryptkey, iv),
encryptdata = encipher.update(cleardata);

encryptdata += encipher.final();
encode_encryptdata = new Buffer(encryptdata, 'binary').toString('base64');
return encode_encryptdata;
}

var cryptkey = crypto.createHash('sha256').update('Nixnogen').digest(),
iv = 'a2xhcgAAAAAAAAAA',
buf = "Here is some data for the encrypt", //32 chars
enc = AESCrypt.encrypt(cryptkey, iv, buf);
var dec = AESCrypt.decrypt(cryptkey, iv, enc);

console.warn("encrypt length: ", enc.length);
console.warn("encrypt in Base64:", enc);
console.warn("decrypt all: " + dec);

source d'informationauteur Justin Cloud