Beginner Topic 4 of 51 Security & Cryptography
Salting
Adding random data to hashes to defeat precomputed attacks.
How it works
A salt is a random value, unique for each password, that is combined with the password before hashing and stored alongside the hash. It ensures that two users with the same password get different hashes and defeats precomputed rainbow tables, forcing attackers to attack each hash separately. Salts are not secret and should be at least 16 bytes from a cryptographically secure random generator. A pepper is a separate secret kept outside the database.
Step-by-step walkthrough
- A user picks a password.
- The system generates a random salt for that user.
- It hashes the password together with the salt.
- It stores the salt and hash.
- Identical passwords now produce different hashes, defeating rainbow tables.
Where it is used
Password storage libraries such as bcrypt, scrypt and Argon2 generate and embed salts automatically in their output string.
Common pitfall
Reusing one global salt or using predictable values like usernames weakens the protection. Salting does not make weak passwords strong or slow down hashing by itself, so combine it with a slow algorithm. Do not invent your own scheme; use a vetted library and verify with constant-time comparison.
Where it fits in the course
Salting is topic 4 of 51 in Security & Cryptography, rated Beginner. It follows Passwords and Hashing. The next topic is Multi-Factor Authentication.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Security & Cryptography quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Security & Cryptography quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Salting?
Where do people use Salting?
What is the most common mistake with Salting?
What should I learn before this topic?
How can I practice it?
Is Salting hard to learn?
How long does it take to learn Salting?
Which topics are related to Salting?
What should I study after Salting?
Related topics
- Passwords and Hashing (Security & Cryptography)
- Multi-Factor Authentication (Security & Cryptography)
- Threats and Vulnerabilities (Security & Cryptography)
- Malware Types (Security & Cryptography)