Overview
A salt is what makes hashed passwords resistant to precomputation attacks and ensures identical passwords do not share hashes. This lesson covers salting.
Learning objectives
- Define a salt and its purpose.
- Explain how salts defeat precomputation (rainbow tables).
- Describe correct salt usage.
Core concept
A salt is a unique, random value combined with each password before hashing, and stored alongside the resulting hash. Its purposes: (1) make identical passwords produce different hashes (so equal passwords are not visible as equal), and (2) defeat precomputation attacks like rainbow tables, because a precomputed table would have to be built per-salt, which is infeasible when each password has a unique salt. Salts are not secret — their value is in being unique per password.
How it works
When a password is set, the system generates a random salt, hashes the salt+password (with a slow algorithm), and stores the salt and hash. At login, it retrieves the salt, hashes the submitted password with it, and compares. Because each user has a different salt, attackers cannot use a single precomputed table against all hashes — they must attack each hash individually. This, combined with slow hashing, makes large-scale cracking dramatically harder. Missing or reused salts reintroduce precomputation and equal-hash weaknesses, so unique per-password salts are essential.
Practical example
Two users happen to choose the same password. Without salts (or with a shared salt), their stored hashes would be identical — visible to an attacker, and crackable once for both via a rainbow table. With unique per-user salts, their hashes differ, and no precomputed table applies — each must be cracked separately and slowly. An assessment finding "passwords hashed without unique salts" would recommend adding a unique random salt per password.
Cybersecurity relevance
Salting is essential to secure password storage: without unique salts, even hashed passwords are vulnerable to rainbow-table precomputation and reveal password reuse across accounts. Missing or improper salting is a recognized weakness that has contributed to large-scale credential compromises. Note that modern adaptive password hashes (bcrypt/Argon2/etc.) handle salting internally, which is another reason to use them. The lesson reinforces the web-security storage guidance and is defensive: always use unique per-password salts (typically via a proper adaptive hash).
Common mistakes
- Not salting, enabling rainbow-table attacks and exposing password reuse.
- Reusing a single salt for all passwords, largely defeating the purpose.
- Thinking salts must be secret — their value is uniqueness, not secrecy.
Key takeaways
- A salt is a unique, random per-password value hashed with the password (and stored with the hash); it need not be secret.
- Salts make identical passwords hash differently and defeat precomputation (rainbow tables) by forcing per-hash attack.
- Unique per-password salts are essential; adaptive password hashes handle salting internally — missing/reused salts are a serious weakness.
Check your understanding
- How does a unique per-password salt defeat rainbow-table (precomputation) attacks?
- Why don't salts need to be kept secret, and what property must they have?

