Educatifu
Open menu

Hashing — a fingerprint for data

A hash turns any data into a short, fixed fingerprint that changes completely if the data changes at all — and can't be run backwards. It underpins integrity checks and password storage.

FoundationsCyber Security~12 min

Before this lesson

  • Lesson: What security actually protects

A cryptographic hash function takes any input — a word, a file, a whole disk — and produces a short, fixed-length digest (SHA-256 always outputs 256 bits, 64 hex characters). It is one of the most useful tools in all of security, and it has three defining properties.

The three properties

  1. Deterministic — the same input always produces the same digest. Hash a file today and next year; identical bytes give an identical hash.
  2. One-way — from a digest you cannot feasibly recover the input. The function is easy to run forwards and effectively impossible to run backwards.
  3. Avalanche — change the input by a single bit and roughly half the output bits flip. Similar inputs give completely dissimilar digests, so a digest leaks nothing about how close two inputs were.

A fourth, related property is collision resistance: it should be infeasible to find two different inputs with the same digest. (This is why old hashes like MD5 and SHA-1 were retired — collisions became findable.)

See the avalanche

Below, type any text and watch its real SHA-256 digest. The widget also hashes the same text with a single character changed and highlights how many digits differ — usually about half. Tiny change in, total change out.

What hashes are for

  • Integrity — publish a file's hash; anyone can re-hash their copy and confirm it matches, proving it wasn't corrupted or tampered with in transit. This is how downloads, software updates and blockchains detect changes.
  • Password storage — a service should never store your actual password. It stores its hash; at login it hashes what you typed and compares. A breach then leaks hashes, not passwords.

The password caveat

Plain fast hashing is not enough for passwords, and this is where beginners get it wrong. Attackers precompute hashes of common passwords, so real systems add two things: a salt (a unique random value per password, so identical passwords get different hashes and precomputation fails) and a deliberately slow hashing scheme (bcrypt, scrypt or Argon2) that makes billions of guesses per second impractical. Same core idea, hardened for adversaries.

Hashing gives us integrity and lets us check secrets without storing them. But it does not let two parties share a secret to keep messages confidential. For that we need keys — and a surprising trick for agreeing on one in the open. That's next.

Try it: hashing and the avalanche effect

SHA-256 of your text

SHA-256 with one character changed → "Hello"

Changing a single character flipped 0 of 64 hex digits (0%). The output looks unrelated — that is the avalanche effect. And there is no way to run SHA-256 backwards: from a digest you cannot recover the text, which is why systems store the hash of a password, never the password.

Key takeaways

  • A cryptographic hash maps any input to a fixed-size digest; the same input always gives the same digest.
  • It is one-way (you can't recover the input) and avalanching (one changed bit flips about half the output).
  • Hashes verify integrity and store passwords — but passwords need salting and a slow hash, not a plain fast one.

← All Cyber Security lessons

Bring us the problem, not a perfect specification

Tell us what needs to change, who it affects and any important deadline. We will review the context and reply with useful next questions.

  1. 01Share contextDescribe the workflow, constraint or risk.
  2. 02Clarify togetherWe identify missing facts and useful options.
  3. 03Choose a startAgree a focused assessment or delivery step.
Start a conversation