2
我試圖使用本地密碼模塊在我的應用程序的NodeJS,但我不斷收到取消消息:NodeJS 6加密抱怨在棄用消息中摘要?
(節點:26)DeprecationWarning:crypto.pbkdf2而不指定 摘要已被棄用。請指定消化
我知道這是由於改變組預計摘要前進: https://github.com/nodejs/node/pull/4047
但是,從我所看到的,我的代碼正好是as outlined in the 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)
})
}
注意:如果這有什麼差別,這是slim version of the node:6
有意思......如果我在碼頭集裝箱外面運行這個,我沒有收到這個消息...將會挖掘更多...... – gordysc