Closed Aashir1 closed 6 years ago
i resolved this issue by replacing salt value 20 to 10.
Rounds >13 will take a long time to complete. Refer to the table in the README for details.
Any particular reason you need to use hashSync
?
I had the same problem, Now I use in a easier way:
const bcrypt = require("bcryptjs");
let hash = bcrypt.hashSync("myPassword", 10);
console.log(hash);
if (bcrypt.compareSync("myPassword", hash)) {
// Passwords match
console.log("Passwords match");
} else {
// Passwords don't match
console.log("Passwords don't match");
}
Wrapping process.env.SALT
solved this problem for me.
My Node getting stuck on bcrypt.hash and bcrypt.hashSync. However, if I comment these statement my code going well. I am being hangout in this error since morning. This is my code.
userDocument.password = bcrypt.hashSync(userDocument.password, salt);
bcrypt.hashSync(userDocument.password, salt, (err, hash) => {
if (!err) {
userDocument.password = hash;
console.log('userDocument.password: ', userDocument.password)
console.log("userDocument: ", userDocument);
console.log('userDOcument: ', userDocument);
userDocument.save((err, user) => {
if (!err) {
delete user.password;
console.log('if from controller', user);
return AuthController.sendResponse(res, user);
}
if (err.code == 11000) {
let error = {
code: err.code,
message: err.message
}
return AuthController.throwError(res, error, 400);
}
})
}
})