Reputation: 5647
I'm trying to configure Bcrypt for a node app that I'm making and have several questions about salts that I hope someone here can help kindly answer.
What is a salt 'round'? For example, in the github docs (https://github.com/kelektiv/node.bcrypt.js/) it uses a salt round of 10. What does that mean exactly?
Is the salt generated by Bcrypt always the same? For example, if I am saving user's hashed passwords to a DB, is the salt that it used to hash the password the same for every password?
How is the salt stored? Is it secure from potential attacks?
Upvotes: 77
Views: 66475
Reputation: 1
Rounds equal 10 means that 2^10 iterations that algorithm hashing takes to hash the password 🔑, the more rounds the more cpu time takes and more encrypted password from brute-forces attacks
Upvotes: 0
Reputation: 371
Salt is included in hash only and we need not to remember while comparing.
var myPlaintextPassword='Saifio';
var saltRounds = 10;
const hash = bcrypt.hashSync(myPlaintextPassword, saltRounds);
$2b$10$nOUIs5kJ7naTuTFkBy1veuK0kSxUFXfuaOKdOKf9xYT0KKIGSJwFa
| | | |
| | | hash-value = K0kSxUFXfuaOKdOKf9xYT0KKIGSJwFa
| | |
| | salt = nOUIs5kJ7naTuTFkBy1veu
| |
| cost-factor = 10 = 2^10 iterations
|
hash-algorithm = 2b = BCrypt
Upvotes: 24
Reputation: 24071
Upvotes: 115