Skip to content
uencoder

Salt

A salt is a random value added during password hashing so identical passwords produce different hashes, defeating rainbow tables and same-password detection.

Purpose

To make every user password hash unique even for identical passwords, preventing precomputation and bulk comparison.

Mechanism

Generate a unique random salt (≥16 bytes) per password and hash the concatenation: H(password || salt). The salt is stored alongside the hash (no secrecy needed). On verification, re-hash with the stored salt and compare. Salting forces rainbow tables to be precomputed per user, which is infeasible.

Use cases

  • Password hash storage
  • KDF (PBKDF2/scrypt) input
  • Encryption IV analogy
  • Token generation

Examples

  • Input
    password + random salt
    Output
    Unique hash

    Different per user

Common errors

A global fixed salt (equivalent to no salt)
Generate a unique random salt per password

Related terms

Related tools

References