这是我的散列密码和比较现有的密码与密码现有的模块已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