Skip to content
uencoder

Hash Salting

Hash salting is adding a random salt to the hash input so identical inputs produce different hashes, defeating rainbow tables and collision detection.

Purpose

To make hash outputs unique, preventing precomputation attacks and comparison of identical inputs.

Mechanism

Generate a random salt, compute H(input || salt), and store (salt, hash). On verification, re-hash with the stored salt and compare. The salt need not be secret but must be unique. Used for password hashing, HMAC (though HMAC already embeds a key), and similar scenarios.

Use cases

  • Secure password storage
  • Token generation deduplication
  • Data fingerprint deduplication
  • Precomputation attack prevention

Examples

  • Input
    pass1 + saltA → hashA; pass1 + saltB → hashB
    Output
    Same password, different hashes

    Unique salt

Common errors

Salt too short (<16 bytes)
Use at least 16 random bytes

Related terms

Related tools

References