What Is Password Salting?
Salting adds a unique, random value to each password before hashing it, ensuring that identical passwords produce different stored hashes.
Published November 17, 2026
Salting adds a unique random value to each password before hashing, so identical passwords produce different hashes and precomputed rainbow tables become useless.
The concept
Without a salt, everyone who uses 'password123' has the same hash, and one cracked hash exposes them all. With a per-user random salt each hash must be attacked separately.
The salt is not secret and is stored with the hash. Modern functions like bcrypt and Argon2 generate and embed it automatically.
Same password, different hashes
user A: hash('hunter2' + 'x9f3') = 7c1a…
user B: hash('hunter2' + 'q2m8') = e904…
Practical examples
bcrypt includes the salt
import bcrypt from 'bcrypt'
const h = await bcrypt.hash('hunter2', 12) // $2b$12$<salt><hash>
await bcrypt.compare('hunter2', h) // truePHP
password_hash('hunter2', PASSWORD_DEFAULT);What not to do
md5($password) // no salt, fast: neverCommon mistakes
- Using one global salt for everyone.
- Rolling your own salting scheme.
- Using fast hashes like SHA-256 for passwords.
Key takeaways
- Unique random salt per password.
- Defeats rainbow tables.
- Use bcrypt/Argon2, which handle it.
FAQ
Is a salt secret?
No; secrecy comes from the password and a slow hash.
What is a pepper?
A secret value stored outside the database and added before hashing.