I’m building a web app with user authentication, and I want to make sure passwords are stored securely. What’s the best approach to hashing and salting passwords before storing them?
The best approach for storing passwords securely is:
const bcrypt = require('bcrypt');
const saltRounds = 10;
bcrypt.hash('password123', saltRounds, function(err, hash) {
// Store the hashed password in the database
});
Never store plain-text passwords. Always hash and salt passwords before saving them.