node.js - 解密时加密更新不起作用
问题描述
创建密码时,此方法有效
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);
解决方案
推荐阅读
- javascript - 对 className 风格技术做出反应的最佳实践
- reactjs - React 创建一个可重用的 Modal
- json - 你如何在 Golang 中修改这个结构来接受两个不同的结果?
- javascript - 如何在 javascript 中的数字字符串之间放置分隔符,例如我有 123456,我想要 123,456 或 1000000 到 1,000,000
- android - 无法在布局 xml 中添加卡片视图
- postgresql - 如何在 SQL/PostgreSQL 中显示分数?
- r - 在ggplot中过滤多年的月份
- python - 当我在odoo 12中调用操作按钮时如何保持向导在后台打开
- git - 使用一个命令动态创建 .gitmodules 并克隆/拉取所有存储库
- sql - 如何使用while循环遍历表并创建另一个具有所需值的表