Every message has a fingerprint.
A hash function turns any input, a word or a whole movie, into a short fixed-size fingerprint. Type below and watch the SHA-256 fingerprint of your message, drawn as 64 colors. Change a single character and the whole thing reshuffles.
Six algorithms, one message
Every row below hashes the message you typed above, live. Notice three things: the same input always gives the same output, the output length never changes no matter how much you type, and nothing about the output hints at the input.
What actually gets hashed: bytes
Hash functions never see letters, only bytes. Plain English letters take one byte each in UTF-8. Try an accented letter or an emoji: it takes two to four bytes (highlighted).
Hex, Base64 and binary are the same hash. They’re just different ways to write the same bits. Hex uses 4 bits per character, Base64 uses 6, binary uses 1. Switch formats above and the fingerprint stripes stay identical.
Why there’s no HMAC for CRC32. CRC32 is linear: an attacker can change a message and calculate exactly how to fix the checksum, key or no key. HMAC needs a cryptographic hash underneath, so the CRC32 row turns itself off when you enable a key.
MD5, SHA-1 and SHA-256 are Merkle–Damgård designs: the input is padded and processed in 64-byte blocks, and the output is the final internal state. SHA-512 uses 128-byte blocks. SHA3-256 is a sponge (Keccak) and releases only part of its 1600-bit state. That difference is why plain SHA-256 is vulnerable to length-extension attacks and SHA-3 is not. See the HMAC lab.
The avalanche effect
A good hash spreads every tiny change across the whole output. Change one character in message B and count how many output bits flip. The target is about half.
The line in the middle marks 50%.
Each square is one output bit. Pink dots are bits that differ between A and B.
Run the experiment 300 times
One trial can be lucky. This picks 300 random messages, changes one character in each, and plots how many output bits flipped. A strong hash forms a tight bell around 50%.
Line them up
Hex digits that differ between the two hashes are highlighted.
Collisions and the birthday paradox
A collision is two different inputs with the same hash. They must exist, because there are infinitely many inputs and only so many outputs. The question is how hard they are to find. To make it possible here, we chop SHA-256 down to just a few hex digits.
That’s the birthday paradox: with N possible values you expect a repeat after roughly √(πN/2) tries, not N. In a room of 23 people, two probably share a birthday.
Hunt by hand
Type words and add them. Try it at 1 or 2 digits.
Let the computer hunt
It hashes random strings until two truncated hashes match.
Bars show tries per run; the dashed line is the birthday estimate.
A real MD5 collision
These two 128-byte inputs are different (six bytes are highlighted), yet MD5 gives them the identical hash. This published pair, from Xiaoyun Wang and colleagues’ 2004 attack, is why MD5 is retired for security use.
Collision resistance is half the bit length: a 256-bit hash gives about 2¹²⁸ security against collisions. SHA-1’s 160 bits should mean 2⁸⁰ work, but the 2017 SHAttered attack needed only about 2⁶³, and later chosen-prefix attacks made it cheaper still. MD5 collisions now take seconds on a laptop.
Proof of work
Since you can’t steer a hash, the only way to get one that starts with zeros is to keep guessing. Blockchains use this as a costly puzzle: change the nonce, hash, repeat, until the hash starts with enough zeros.
Each extra zero makes the puzzle 16 times harder. Yet anyone can check a solution with a single hash. Hard to find, instant to verify: that asymmetry is the whole idea.
Catch the tampered download
The publisher of an installer script lists its SHA-256 on their official site. You found it on three mirrors. They look the same, but only one is genuine. Hash each and decide which to trust.
The published hash only helps if you get it from a source the attacker can’t also change, ideally a different channel. A hash on the same compromised mirror proves nothing. That’s why serious projects also sign their hashes.
Hash your own file
Your file never leaves your browser; everything is computed on this page.
Drop a file here or
Alice, Bob, and Mallory in the middle
Alice sends Bob a message with a tag attached so Bob can detect changes. Mallory controls the network. Play Mallory in both modes and see which one stops you.
Alice
Shared key with Bob: bluebird-42
Tag
Mallory
Bob
Received message
Received tag
Tag Bob computes
The lesson. A plain hash detects accidents, but anyone can compute SHA-256, so Mallory just recomputes it. HMAC mixes in a secret key that only Alice and Bob know, so Mallory can’t produce a valid tag for her new message.
Why not just tag = SHA-256(key ‖ message)? Because SHA-256 outputs its full internal state, an attacker who sees a tag can keep hashing from it and append data, producing a valid tag for message ‖ padding ‖ extra without the key. This is a length-extension attack. HMAC’s nested construction, H((K⊕opad) ‖ H((K⊕ipad) ‖ m)), blocks it. SHA-3 is immune by design.
How not to store passwords
A website was breached and its user table leaked. The passwords were hashed, so they’re safe… right? Attackers keep giant tables of precomputed hashes for common passwords. Run the lookup.
| User | Salt | Stored MD5 hash | Attacker’s result |
|---|
Spot the problem before you even crack anything: two users have the identical stored hash, so they have the same password.
Make each guess expensive
Salt stops precomputed tables, but MD5 and SHA-256 are still far too fast; a GPU tries billions per second. Password hashing functions repeat the work on purpose. Slide the cost and feel it.
OWASP currently suggests at least 600,000 iterations for PBKDF2-HMAC-SHA256. The attacker estimate assumes a GPU rig doing 10 billion SHA-256 operations per second; it’s a rough illustration, not a benchmark.
PBKDF2 is slow but cheap in memory, so GPUs and ASICs still parallelize it well. bcrypt adds some memory pressure; scrypt and Argon2id are memory-hard, forcing each guess to use many megabytes, which kills the GPU advantage. Argon2id is the current default recommendation for new systems.
Check yourself
Questions match the level you chose at the top. Score 80% or better to earn the badge. Switch to a higher level for harder questions.