问题描述
我该怎么做才能将密码散列并用于在数据库中插入
const company = req.params.company;
const name = req.params.name;
const password = req.params.password;
bcrypt.hash(password,saltRounds,(err,hash) => {
});
如果我使用const密码,它将通过而不会被散列
解决方法
使用哈希参数,该哈希参数为回调返回哈希值。
bcrypt.hash(password,saltRounds,(err,hash) => {
const object = {
company,name,password: hash;
}
await db.save(object);
});