繁体   English   中英

NodeJS 6 crypto抱怨弃用消息中的摘要?

[英]NodeJS 6 crypto complaining about digest in deprecation message?

我试图在我的NodeJS应用程序中使用本机加密模块,但我不断收到弃用消息:

(节点:26)不建议使用警告:不指定摘要的crypto.pbkdf2已弃用。 请指定摘要

我知道这是由于预期摘要会向前发展的变更集造成的: https//github.com/nodejs/node/pull/4047

但是,据我所知,我的代码完全遵循docs中概述的语法。 其他人看到我在做什么错吗?

function verify (password, expected, callback) {
  const combined = Buffer.from(expected, 'base64')
  const saltBytes = combined.readUInt32BE(0)
  const hashBytes = combined.length - saltBytes - 8
  const iterations = combined.readUInt32BE(4)
  const salt = combined.slice(8, saltBytes + 8)
  const hash = combined.toString('binary', saltBytes + 8)
  return crypto.pbkdf2(password, salt, iterations, hashBytes, 'sha512', (err, verify) => {
    if (err) return callback(err, false)
    return callback(null, verify.toString('binary') === hash)
  })
}

注意 :如果有什么不同,这是在节点瘦版本内部执行的:6

经过大量的挖掘,我终于弄清楚了。 它与上面的代码段无关。 我正在使用模块,当前版本为4.0.0。 当前发布的版本未传递摘要的参数,这导致生成警告消息。

他们已经提交了纠正此问题的代码 ,但尚未发布。 这应该很快解决。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM