crypto.scrypt -> createDecipheriv -> 错误节点

问题描述

我遇到了一个问题,我试图从输入密码中导出 256 位密钥,希望将它与 crypto.createCipheriv/createDecipheriv 一起使用。这给了我以下错误[ERR_INVALID_ARG_TYPE]: the "key" argument must be of type string or an instance of Buffer,TypedArray,DataView,or KeyObject. Recieved undefined 我不知道为什么... this.key = crypto.scrypt(this.passphrase,'baewithsalt',256,(err)=>{if(err) throw err;}); 用于... this.decipher = crypto.createDecipher(this.algorithm,this.key,this.iv); 告诉我密钥未定义。我在上面初始化了这些变量... this.passphrase ='whatever'; this.algorithm = 'aes-256-cbc'; this.iv =crypto.randomBytes(16); 我做错了什么,为什么我不能使用 scrypt 从 cipheriv/decipheriv 的密码生成密钥?如果格式可能稍有偏差,我深表歉意,我的互联网已关闭,我是通过手机输入的。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)