Password Attacks & Cryptography · beginner · ~11 min

Hashing: integrity, identification, and its limits

Explain cryptographic hash properties and where hashing is the wrong tool.

Overview

A cryptographic hash is a deterministic, one-way, collision-resistant, fixed-size digest. Use it for integrity, identification, and (with slow variants) password verification. It is not encryption or confidentiality; MD5/SHA-1 are broken for collisions — prefer SHA-256/SHA-3.

Why it matters

Hashing underpins integrity checks, signatures, and password storage, and its misuse ('hashing = encryption', hashing guessable data, using MD5/SHA-1) is a recurring finding. Recognising hash types also drives cracking strategy.

Core concepts

Properties. Deterministic, one-way, collision-resistant, avalanche. Uses. Integrity, identification, password verification. Not. Encryption / confidentiality; guessable inputs are reversible by brute force. Hygiene. Avoid MD5/SHA-1 for collisions; SHA-256/SHA-3 general.

Lesson

A cryptographic hash maps any input to a fixed-size digest (e.g. SHA-256 → 256 bits). It's one-way and foundational to security.

Properties

  • Deterministic: same input → same digest.
  • One-way (preimage resistance): infeasible to recover the input from the digest.
  • Collision resistance: infeasible to find two inputs with the same digest.
  • Avalanche: a one-bit change flips ~half the output.

What hashing is for

  • Integrity: compare digests to detect tampering/corruption (downloads, files).
  • Identification/dedup: content-addressing, fingerprints.
  • Password verification (with the right, slow hash — see the password lessons).

What hashing is NOT

  • Not encryption: there's no key and no way back (by design). "We hashed it so it's encrypted" is wrong.
  • Not confidentiality: a hash of a small/guessable input (a phone number, a PIN) is trivially reversed by hashing all candidates.

Algorithm hygiene

MD5 and SHA-1 are broken for collision resistance — never use them where collisions matter (signatures, certificates). Use SHA-256/SHA-3 for general hashing. (Password hashing needs deliberately slow functions — a separate lesson.) Hash type recognition (length/format) is also how crackers pick an attack.

Summary

Cryptographic hashes are one-way fixed-size digests for integrity, identification, and password verification — not encryption, and not safe for guessable inputs. Use modern algorithms (SHA-256/SHA-3) and never MD5/SHA-1 where collisions matter.

Practice with these exercises