這是我的散列密碼和比較現有的密碼與密碼現有的模塊已sended對身體要求代碼:BCrypt哈希錯誤
//hash password of document that use this schema
bcrypt.hash(user.password, null, null, function (err, hashed) {
if (err) {
throw err;
} else {
user.password = hashed;
//next api
next();
}
})
});
userSchema.methods.comparePassword = function (password) {
//refer at userSchema
var user = this;
//return method of bcryot library that compare two string: original password and password hashed
return bcrypt.compareSync(password, user.password);
};
但是比較這錯誤信息:
Uncaught, unspecified "error" event. (Not a valid BCrypt hash.)
不幸的是不工作! – DevWeb