Identity and access Salting 4 min read

What is a salt in password hashing?

Two users both pick sunshine1. The site hashes passwords, but without a salt, and the database leaks. What can an attacker tell at a glance?

  1. Same password, same hash

    Each hash looks random, but they aren’t unique. Both sunshine1 rows hold exactly the same hash, so an attacker instantly sees who shares a password, and cracking one cracks both.

    Worse, attackers keep precomputed tables of hashes for millions of common passwords. Without a salt, they just look yours up.

    In short Unsalted hashes give identical passwords away.

  2. A random value per user changes everything

    A salt is a random value, different for every user, mixed into the password before hashing. The two sunshine1 users now get completely different hashes.

    Precomputed tables stop working, because they’d have to be rebuilt for every salt. And attackers can no longer crack every user with one round of guesses; each user has to be attacked separately.

    Two users with the same password sunshine1 each get a different random salt. The salted passwords hash to two completely different values. sunshine1sunshine1+ k9Q…+ T2x…7f3a9c…c01e44…
    Same password, different salt, different hash.

    In short A unique salt makes every user a separate puzzle.

  3. It sits right next to the hash

    The site needs each user’s salt every time they sign in, so it’s stored in the same row as the hash. That’s fine: salts are about being unique, not secret.

    A separate secret mixed into every password and kept apart from the database has a different name: a pepper.

    In short Salts aren’t secret. Their job is to be different for everyone.

What a salt doesn’t do

It doesn’t make a weak password strong. An attacker after one user just tries password123 with that user’s salt. Making each guess expensive is the slow hash’s job.

And one fixed salt for everyone, written in the code, loses most of the point: identical passwords still match, and one table covers your whole database. Salts must be random and unique per user.

Keep this

A unique, random salt per user. Stored right next to the hash, and not secret.

Salts stop attackers cracking everyone at once. They don’t make a weak password strong; that’s why the hash must also be slow.
Random
A fresh value for every user, every time they set a password.
Not secret
Stored beside the hash.
Stops
Precomputed tables and spotting shared passwords.
Doesn’t stop
Guessing one user’s weak password.

Questions worth carrying

How long should a salt be?

Long enough to be unique for every user: 16 random bytes is common. Modern password-hashing libraries generate it for you.

Do I need to manage salts myself?

Usually not. Argon2id, scrypt and bcrypt libraries create the salt and store it inside the hash string.

Sources

Last reviewed 17 November 2026.

Back to · Passwords and MFA What is password hashing?