微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

如何解决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 举报,一经查实,本站将立刻删除。