2016-05-06 26 views
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

+0

有意思......如果我在碼頭集裝箱外面運行這個,我沒有收到這個消息...將會挖掘更多...... – gordysc

回答

0

內部執行多挖我終於想通了之後。它與上面的代碼段無關。我正在使用目前版本爲4.0.0的iron模塊。當前發佈的版本不會傳遞摘要的參數,這會導致生成警告消息。

他們有already committed code to correct this,但它尚未發佈。這應該儘快解決。