"We hash our passwords" is the security equivalent of "we lock the front door." Necessary, and nowhere near sufficient. Without a salt, a stolen hash database can be cracked wholesale.
Ask a team how they store passwords and "we hash them" is meant to end the conversation reassuringly. It shouldn't. Hashing is necessary, but a plain hash — even with a strong algorithm — leaves a password database vulnerable to an attack that cracks not one account but potentially all of them at once. The missing ingredients are a salt and a deliberately slow hash, and understanding why each matters is the difference between a breach that exposes a few weak passwords and one that hands over everyone's.
What a salt is
A salt is deceptively simple. Wikipedia defines it precisely:
"In cryptography, a salt is random data fed as an additional input to a one-way function that hashes data, a password or passphrase."
— Wikipedia, "Salt (cryptography)" (CC BY-SA 4.0)
Random data, mixed into the password before hashing, stored alongside the hash. That's it — and it changes the economics of an attack completely.
The attack a salt defeats
Here's the threat. A hash function is deterministic: the same input always produces the same output. So if a thousand people use the password summer2024, an unsalted system stores the same hash a thousand times. An attacker doesn't even need to crack it live — they can use a rainbow table or a lookup database, giant precomputed lists of common passwords and their hashes, and simply look up matches. Steal an unsalted database and huge swathes of it fall almost instantly, because the hashes are just lookups waiting to happen.
What a per-user salt changes, in numbers
Now give every user their own random salt. The same password now hashes to a different value for every user, because each one's salt is mixed in first. The OWASP Password Storage Cheat Sheet puts the consequence well: the attacker "has to crack hashes one at a time using the respective salt rather than calculating a hash once and comparing it against every stored hash."
A rough illustration makes that concrete. Assume, purely for the arithmetic, a stolen table of 1,000,000 users and an attacker with a list of 10,000,000 likely passwords.
- No salt: hash each candidate once — 10 million hash computations — and compare every result against all million rows at the same time.
- Unique salt per user: every candidate must be hashed separately for every user, 10,000,000 × 1,000,000 = 10 trillion computations. A million times more work for the same list.
The salt doesn't need to be secret — it's stored right next to the hash — because its job isn't secrecy. Its job is to make every hash unique. A 16-byte random salt is plenty: with a million users, the chance that any two of them ever get the same 128-bit salt works out around 1 in 10²⁷ by the birthday approximation (our script is in this draft's checks).
Why a salt alone still isn't enough
Salting multiplies the attacker's work by the number of users. It does nothing about how cheap each guess is. A general-purpose hash such as SHA-256 is designed to be fast: on the ordinary server that ran this draft's checks, 100,000 salted SHA-256 hashes took about 0.05 seconds. If an attacker's hardware managed, say, a billion guesses a second (an assumption for illustration), a full 10-million-word pass against one salted account takes a hundredth of a second, and against all million accounts under three hours.
That's why password hashing uses deliberately slow, memory-hungry functions. OWASP's current recommendations, read on 10 Nov 2026, are:
- Argon2id as the first choice, with a minimum of 19 MiB of memory, 2 iterations and 1 degree of parallelism (or one of its equivalent settings).
- scrypt if Argon2id isn't available, for example N=2^17, r=8, p=1.
- bcrypt only for legacy systems, with a work factor of at least 10 and a 72-byte input limit.
- PBKDF2-HMAC-SHA256 with 600,000 iterations where FIPS-140 compliance is required.
Slow is the feature. Running scrypt at OWASP's N=2^17 setting took roughly half a second to a second on the check machine (timing is machine-dependent) and needed 128 MiB of memory per hash. If an attacker were held to, say, 1,000 guesses a second for that kind of function (again an assumption), the same 10-million-word list against a million salted accounts would take around 317 years of compute instead of three hours. Real numbers depend on hardware; the ratio is the point.
One practical note from OWASP: modern libraries for Argon2id, bcrypt and PBKDF2 usually generate and store the salt for you, inside the encoded hash string. If you find yourself writing salt-handling code by hand, check whether your library already does it.
Why identical passwords must never collide
This is the property to internalise: in a well-built system, no two stored password hashes should be identical, even for users who chose the exact same password. If two rows in your password table share a hash, you have no salt (or a shared one), and you've handed an attacker the "these people used the same password" signal plus rainbow-table vulnerability. A quick audit query — count distinct hash values against row count — is a cheap way to catch it.
Peppering: the extra layer
A pepper is a salt's secret cousin. Where the salt is stored with the hash, a pepper is a single secret value kept separately — in a secrets vault or a hardware security module, not in the database. OWASP describes two patterns: mixing the pepper into the password before hashing, or running the finished password hash through an HMAC keyed with the pepper. Either way, an attacker who steals only the database (through SQL injection, say, or a leaked backup) still lacks the pepper needed to test guesses.
Peppers come with a cost people forget. You can't re-pepper a hash without knowing the user's password, so if the pepper leaks and you rotate it, OWASP notes you'll need to force password resets for everyone it protected. And on its own, a pepper adds nothing; the cheat sheet calls it defence in depth, not a substitute for salting and a slow hash.
Common mistakes
- Reusing one salt for every user. That's a pepper stored in the wrong place: it blocks generic rainbow tables but still lets an attacker crack the whole table in one pass.
- Short or predictable salts, such as the username or the user ID. Use random bytes from a cryptographic generator.
- Fast hash plus salt, then calling it done. Salted SHA-256 is still built for speed.
- Never revisiting the work factor. OWASP suggests re-hashing with stronger settings when each user next logs in.
See the effect for yourself
The concepts click fast when you watch them. Take a hash generator, hash the word password, then hash password with a few random characters prepended — the outputs are completely unrelated, which is the salt's whole trick in one demonstration. (The hash generator uses SHA family functions, which is fine for a demo and wrong for real password storage, for the reasons above.) Generate random test values and strong test passwords with a password generator. "We hash our passwords" is the start of a good answer. "We use Argon2id with a unique salt per password, and a pepper kept outside the database" is the rest of it.