methodEngineering & architecture

Hashing

A one-way computation that maps input data to a fixed-length digest used for integrity, identification, and specialized secret verification.

Download Markdown (.md)

01What it means

A cryptographic hash function maps arbitrary input to a fixed-length digest and is designed to resist reversing the input and finding collisions. Hashing is not encryption because there is no decryption key. Password storage uses dedicated slow, salted password-hashing functions rather than fast general-purpose hashes.[1][2]

One-way digest, not reversible encryption Hashing verifies or indexes input without providing a decryption key
Cryptographic hashing
Input → fixed-length digestIntegrity and signature uses; designed against reversal and collisions
Encryption
Plaintext ↔ ciphertext with authorized key useProtects confidentiality and supports recovery of the original data

Password storage requires a unique salt and a slow adaptive or memory-hard password hash—not a fast general-purpose digest.

02Why it matters

Hashes support integrity checks, digital signatures, content addressing, and password verification without storing plaintext passwords. Choosing the wrong function or omitting salts can make offline guessing and collision attacks practical.

03When to use it

Use approved hashes for integrity and protocol-defined purposes, and a current password-hashing function for stored passwords. Use a message authentication code when integrity must be proven with a shared secret, and encryption when data must later be recovered confidentially.

04How it works

  1. Choose a function designed for the specific integrity, signature, or password-storage purpose.
  2. Normalize and encode input unambiguously before hashing.
  3. For passwords, generate a unique salt and apply a memory-hard or approved adaptive password hash with tuned cost.
  4. Store the algorithm, parameters, salt, and digest rather than the password.
  5. Compare results safely and upgrade weak parameters after successful authentication.

05A practical example

Example

A product stores each password with Argon2id, a unique random salt, and recorded work parameters. On login it recomputes the digest, compares it safely, and rehashes successful logins when the cost policy increases.

06Where it breaks

Hashing does not hide low-entropy input from offline guessing, authenticate an untrusted digest, or preserve data for recovery. Algorithm safety changes, and collision resistance alone is not sufficient for every protocol.

Common mistakes

  • Storing passwords with a fast hash such as plain SHA-256.
  • Using one salt for every account or treating a salt as a secret.
  • Using a bare hash where an HMAC or digital signature is required.
  • Describing base64 encoding or reversible encryption as hashing.

07Sources

  1. Secure Hash Standard (FIPS 180-4)NIST · Government standardSecure Hash Standard (FIPS 180-4)
  2. Password Storage Cheat SheetOWASP Foundation · Security practice guidancePassword Storage Cheat Sheet
View saved topics

Start typing to search titles, definitions, categories, and frameworks.