Nodejs Crypto 解密报错“wrong final block length”
发布于 11 年前 作者 eagleChina 19614 次预览 最后一次回复是 10 年前 来自 问答
TypeError: error:0606506D:digital envelope routines:EVP_DecryptFinal_ex:wrong final block length at Decipher.Cipher.final (crypto.js:292:27) at Object.module.exports.decrypt
我用crypto模块加密的数据, 在解密的时候出现了这个错误 以下是我方法源码 function encrypt(str, secret) { var cipher, enc; cipher = crypto.createCipher(‘aes-256-cbc’, secret); enc = cipher.update(str, ‘utf8’, ‘hex’); enc += cipher.final(‘hex’); return enc; }, function decrypt(str, secret) { var dec, decipher; decipher = crypto.createDecipher(‘aes-256-cbc’, secret); dec = decipher.update(str, ‘hex’, ‘utf8’); dec += decipher.final(‘utf8’); return dec; }
2 回复
我这边是ok的。
你两个方法用反了…