← All animations

#️⃣ Hash Functions

A hash function takes any input — a word, a file, a whole movie — and crunches it into a short, fixed-size fingerprint. The same input always gives the same fingerprint; the tiniest change gives a wildly different one; and you can't run it backwards to recover the input. That one-way scrambling quietly secures your passwords, your downloads, git, and the entire blockchain. Scroll through and feel it work.

1. Type something — watch the fingerprint SHA-256

Whatever you type gets hashed instantly into a fixed 256-bit (64 hex-digit) string. Now look at the two boxes: the second input is your text plus one extra character. One tiny change, yet roughly half the output bits flip — the avalanche effect. Highlighted nibbles below show every hex digit that differs. The colour grid is the same hash drawn as a fingerprint: each pair of digests looks nothing alike.

Input A:
Input B (A + one char):
bits flipped: …

The grid maps each hash byte to a colour cell, left-to-right top-to-bottom. Genuine output: a one-character change reshuffles almost the whole grid.

2. What makes it useful — and a miner you can run

Four properties do all the heavy lifting:

Password storage. Never store the plaintext. Store hash(salt + password) plus the random salt. At login you re-hash what's typed and compare. A leak exposes only hashes; the salt makes precomputed "rainbow table" lookups useless because every user's hash is different even for the same password.

Password typed
Per-user salt (random)
Stored on the server (never the password)

Change one letter of the password and the stored value changes completely — that's what lets the server check it without ever knowing it.

Proof of work. One-wayness made tangible: find an input whose hash starts with N zeros. There's no shortcut — you just hash "block" + nonce for nonce = 0, 1, 2, … until you get lucky. Each extra zero is ~16× more work. This is exactly how Bitcoin mining works.

target: 000…
Press Mine to start hashing.

3. The big picture — verify without inverting

A hash is a fingerprint for data. You can't reconstruct a person from their fingerprint, but if two fingerprints match you can be confident it's the same person. Hashes work the same way: you can always verify (re-hash and compare) but you can never invert (turn a hash back into the original). That asymmetry — cheap one way, infeasible the other — is the whole point.

It's why a download site can publish a checksum: re-hash the file you got and compare; a single flipped bit during transfer would produce a totally different hash and expose the corruption. It's why servers store salted password hashes instead of passwords. And it's why tamper-evidence works:

Use a cryptographic hash (SHA-256, SHA-3, BLAKE2) for security; fast non-cryptographic hashes (CRC32, FNV) are fine for hash tables but trivially forgeable.