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; }
我这边是ok的。
➜ crypto node -e "console.log(process.versions)"
{ http_parser: '1.0',
node: '0.10.32',
v8: '3.14.5.9',
ares: '1.9.0-DEV',
uv: '0.10.28',
zlib: '1.2.3',
modules: '11',
openssl: '1.0.1i' }
你两个方法用反了…