Skip to content
eastbaycyber

Disclosure: this page contains affiliate links. East Bay Cyber may earn a commission if you buy through them, at no extra cost to you. That never changes how we rank products. Editorial policy.

What Is Salting?

Glossary 9 min read
EC
East Bay Cyber Editorial Team Updated
Definition

A salt is a unique random value generated for a password before the password is hashed and stored. The salt is combined with the password, and the result is processed through a password hashing function.

Salting is the practice of adding unique random data to a password before hashing it for storage. In password security, salting ensures that even if two users choose the same password, their stored password hashes will be different. That makes stolen credential databases harder to crack efficiently and reduces the value of precomputed attacks such as rainbow tables.

Salting is a basic part of secure password storage, but it works best when combined with a proper password hashing algorithm like Argon2, bcrypt, or scrypt. For related background, see what is hashing and what is mfa.

Salting at a glance#

Term What it is Where it lives What it defends against
Hash One-way output of a password hashing function Credential database Storing plaintext passwords
Salt Unique random value generated per password (NIST SP 800-63B requires at least 32 bits; 16 bytes is common) Stored next to the hash; not secret Rainbow tables, spotting users who share a password
Pepper Secret value applied to all passwords Outside the database (secrets manager or HSM) Offline cracking when only the database leaks
Key stretching Deliberately slow, tunable hashing (Argon2id, scrypt, bcrypt, PBKDF2) Algorithm cost parameters Fast brute-force guessing

Example: two users both pick Summer2026!. Without salts, the database stores the same hash twice, so cracking one cracks both and reveals that they match. With a per-user salt, each stored hash is different, and an attacker has to attack every account separately.

How salting works#

Salting is part of the password storage process, not a replacement for hashing.

A unique salt is generated

When a user creates or changes a password, the application should generate a unique random salt for that password.

A properly designed system then:

  • Creates a random salt
  • Combines the salt with the password
  • Hashes the result with a password hashing algorithm
  • Stores the salt and resulting hash

The password itself should never be stored in plaintext.

The salt changes the hash output

Without salting, two users who pick the same password will end up with the same stored hash. That creates an obvious weakness because an attacker who steals the database can quickly identify matching passwords across accounts.

With salting:

  • User A and User B can choose the same password
  • Each user gets a different random salt
  • Each stored hash comes out differently

This prevents attackers from looking at a database and instantly grouping all users with the same password.

The system verifies logins with the stored salt

When the user logs in later, the system does not decrypt the stored value. Instead, it:

  • Retrieves the user’s stored salt
  • Combines that salt with the submitted password
  • Hashes the combination again using the same algorithm and settings
  • Compares the result with the stored hash

If the values match, the login is accepted.

This is why the salt does not need to be hidden. Its job is uniqueness, not secrecy.

Why salting matters#

Salting improves password storage by making offline cracking less efficient.

It stops identical-password matching

If a breached database contains unsalted hashes, matching hashes often reveal that multiple users share the same password. That gives attackers immediate insight into password reuse patterns.

Salting prevents that shortcut because the same password produces different stored outputs for different users.

It weakens rainbow table attacks

A rainbow table is a precomputed mapping of common passwords to their hash values. These tables are useful against unsalted hashes because the attacker can compare stolen hashes against known values quickly.

Salting breaks that efficiency. Because each password hash uses a different salt, the attacker would need separate precomputation for each unique salt. That makes rainbow tables far less practical.

It forces attackers to work account by account

When salts are unique, an attacker cannot crack one hash and automatically apply that result across every account with the same password hash. They have to work on each record more individually.

That does not make password cracking impossible, especially if users choose weak passwords. But it raises the cost significantly.

Salting is not enough on its own#

Salting is necessary, but it is not the whole answer.

If a system salts passwords and then uses a fast general-purpose hash like SHA-256, the hashes may still be crackable at high speed with modern hardware. Best practice is to combine salting with a password hashing algorithm designed specifically for credential storage.

Common choices include:

  • Argon2
  • bcrypt
  • scrypt

These algorithms are deliberately slower and more resource-intensive than general-purpose hashes, which makes brute-force cracking more expensive.

Two public references set the baseline most security reviews check against: NIST SP 800-63B (Digital Identity Guidelines, revision 4) and the OWASP Password Storage Cheat Sheet.

Setting What the guidance says Source
Salt length At least 32 bits, chosen to minimize salt collisions among stored hashes NIST SP 800-63B-4
What to store Both the salt and the resulting hash, for each password NIST SP 800-63B-4
Hashing scheme Passwords must be salted and hashed with a suitable password hashing scheme; cost factor as high as practical and raised over time NIST SP 800-63B-4
Argon2id (first choice) Minimum 19 MiB memory, 2 iterations, parallelism 1 OWASP Cheat Sheet (parameters per RFC 9106)
scrypt Minimum N=2^17 (128 MiB), r=8, p=1 OWASP Cheat Sheet
bcrypt (legacy systems) Work factor 10 or more; most implementations only use the first 72 bytes of input OWASP Cheat Sheet
PBKDF2 (FIPS-140 contexts) 600,000 iterations with HMAC-SHA-256 OWASP Cheat Sheet
Secret key / pepper Optional extra keyed step with a secret stored apart from the hashes, ideally in an HSM NIST SP 800-63B-4 (SHOULD), OWASP Cheat Sheet

In practice you rarely generate salts by hand. Mainstream Argon2, bcrypt and scrypt libraries create a random salt for each call and store it inside the encoded hash string, as in the bcrypt example below. The places where salts still go wrong are custom code paths: a hard-coded or global salt, a salt from a non-cryptographic random function, or a fast hash such as plain SHA-256 used instead of a password hashing scheme.

When you will encounter salting#

You are most likely to encounter password salting in discussions about password storage, authentication security, and breach impact.

Common situations include:

  • Application development: Developers need to store user passwords safely
  • Security reviews: Auditors check whether password hashes are salted and properly hashed
  • Incident response: Teams assess how hard stolen password databases will be to crack
  • Identity platform migrations: Legacy systems may still use weak or outdated storage methods
  • Compliance assessments: Organizations review whether credential handling meets current standards

If a company says passwords were “salted and hashed,” that is generally much better than storing plaintext passwords or unsalted hashes, though the exact security still depends on the hashing algorithm and configuration used.

Salting vs hashing

Hashing turns input data into a fixed-length output. Salting adds unique random data before hashing so that identical passwords do not generate identical stored hashes.

Salting vs encryption

Encryption is reversible if you have the key. Password storage should generally rely on hashing, not encryption, because the system does not need to recover the original password.

Salting vs peppering

A pepper is an additional secret value used during password hashing, typically stored separately from the database. Unlike a salt, a pepper is meant to remain secret. Peppering can add defense in depth, but it does not replace salting.

Salting vs MFA

Salting protects stored password hashes if a database is stolen. MFA reduces the damage of a stolen password during login. They solve different problems and work well together.

For stronger account protection overall, users should also use unique passwords managed with a password manager such as Try 1Password →, and endpoints that store or process credentials should be protected with reputable security software like Get Bitdefender →.

Common mistakes with salting#

Salting is widely understood, but implementation mistakes still happen.

Reusing the same salt everywhere

A salt should be unique per password. Using one global salt across all accounts reduces the benefit significantly.

Using weak random generation

Salts should be generated with a cryptographically secure random source. Predictable salts make attacks easier.

Pairing salts with weak hashing

Salting alone does not compensate for the use of fast, outdated, or inappropriate hash functions.

Treating salting as optional

Modern password storage should assume salting by default. Most modern identity frameworks already do this correctly, but older custom systems may not.

Password Salting and Verification Pipeline

Registration:
  Plaintext Password ("Summer2026!")
        + CSPRNG 16-Byte Salt (0x9f3a...c41b)
        ---> Slow KDF (Argon2id / bcrypt, cost=12)
        ---> Stored String: $2b$12$<22-char-salt><31-char-hash>

Login Verification:
  Submitted Password + Extracted Stored Salt
        ---> Recompute KDF with identical cost parameters
        ---> Constant-Time Digest Comparison (hmac.compare_digest)
import bcrypt

# 1. Hashing a new password with a unique cryptographic salt
password = b"correct-horse-battery-staple"
salt = bcrypt.gensalt(rounds=12)          # generates a unique 16-byte CSPRNG salt
stored_hash = bcrypt.hashpw(password, salt)

# 2. Verifying a login attempt (salt is parsed directly from stored_hash)
is_valid = bcrypt.checkpw(b"correct-horse-battery-staple", stored_hash)

Salting FAQ#

Is a salt secret?

No. A salt only has to be unique, so it is stored next to the hash. NIST SP 800-63B requires both the salt and the hash to be stored for each password. A secret value used for every password is a pepper (NIST calls it a secret key), and it is kept outside the database. See what is a pepper.

How long should a salt be?

NIST SP 800-63B sets a floor of 32 bits. Common libraries use more: bcrypt uses a 16-byte (128-bit) salt, encoded as 22 characters in the stored string.

Does salting stop brute-force attacks?

Not on its own. A salt stops precomputed tables and forces an attacker to crack each account separately, but a weak password can still be guessed. The slow, tunable cost of Argon2id, scrypt, bcrypt or PBKDF2 is what makes each guess expensive, and MFA limits what a cracked password is worth.

What does “salted and hashed” mean in a breach notice?

It means passwords were not stored in plain text and each one had its own salt. How much protection that gives depends on the algorithm and cost settings, which notices often leave out. Breach notices usually still ask users to change the password, along with anywhere else it was reused. For the wider topic, see password hashing.

Final takeaway#

Salting is the practice of adding unique random data to a password before hashing it. Its purpose is to make identical passwords produce different stored hashes and to reduce the effectiveness of rainbow tables and large-scale cracking shortcuts.

It is a foundational password security control, but it works best when paired with strong password hashing algorithms like Argon2, bcrypt, or scrypt, plus broader protections such as MFA and unique passwords. If you store user passwords at all, salting should be standard, not optional.

Last verified: 2026-11-02

Disclaimer: This article may contain affiliate links. We earn a commission on qualifying purchases at no extra cost to you.