bcrypt
// npm bcrypt used salt
// code
const bcrypt = require('bcrypt');
// hashing password.(registration)
const hashedPassword = await bcrypt.hash(req.body.password,10);
const user = { name: req.body.username, password: hashedPassword }
// compare password (login)
try {
if (await bcrypt.compare(password, user.password)) {
console.log("login successfull");
} else {
console.log("login failed");
}
} catch (e) {
console.log("something went wrong", error);
}
re.send(user)