bcrypt
と私のアプリケーションでPromiseインターフェイスを実装しています。パスワードを比較するとBcryptがfalseになります
私はパスワードを比較しようとしているとき、同じパスワードであっても、私は虚偽を取得します。
const bcrypt = require('bcrypt');
const saltRounds = 10;
const password = 'secret';
const resHash = ''
/**
* Generate Password
*/
bcrypt.hash(password, saltRounds).then((res) => {
console.log(res)
this.resHash = res
}).catch(err => {
console.log(err)
})
/**
* Compare Password
*/
bcrypt.compare(password, resHash).then((res) => {
console.log("Comparison result: " + res)
}).catch(err => {
console.log(err)
})
私は次の出力を取得しています:
Comparison result: false
boolean
$2a$10$n0mnrLHT3rRkREKB8RJXouMFrhNQjqOFeN7Sq.a.BYXigdBhcBkfq
私が間違って上記の例ではやっているものを任意の提案を?
私のコードを関数に追加してください – mrquad