首页 > 解决方案 > 解密时加密更新不起作用

问题描述

创建密码时,此方法有效

const key = Buffer.alloc(24,process.env.KEY, "base64");

let iv = Buffer.alloc(0);

let cipher = crypto.createCipheriv('des-ede3', key, iv);
let newKey = cipher.update(newApiKey,'utf-8', 'hex');
newKey += cipher.final('hex'); 

但是当试图解密这个时,我得到一个未定义的字符串作为响应

let decipher = crypto.createDecipheriv('des-ede3', key, iv);
let decrypted = decipher.update(newKey, 'hex', 'utf-8');
decrypted += decipher.final('utf-8');
console.log(decrypted);

标签: node.jsencryptioncryptography

解决方案


推荐阅读