Hash functions
A hash function is a machine that turns any data — a word, a book, an entire hard drive — into a short, fixed-length fingerprint. It’s the workhorse of Bitcoin: it links the blockchain together, powers mining, and lets a global network verify data without trusting anyone.
Try it — this is SHA-256, the exact function Bitcoin uses
Type anything below. Your browser computes its SHA-256 hash live — the same 256-bit fingerprint the Bitcoin network computes billions of times a second.
Four properties that make it magic
- Deterministic. The same input always gives the same hash — every computer on Earth agrees. Type “Bitcoin” again and you’ll get exactly the fingerprint above.
- Avalanche. Change a single character — even the capital B — and the hash changes completely, with no resemblance to the old one. Try it: the fingerprint scrambles entirely.
- Fixed length. One word or a whole encyclopedia, the output is always 256 bits (64 hex characters). A fingerprint is always the same size, whatever it summarises.
- One-way. Easy to compute the hash from the data; effectively impossible to work backwards from a hash to the data. It’s a trapdoor — trivial one way, hopeless the other.
Because a hash uniquely fingerprints its input, you can prove two files are identical by comparing 64 characters instead of the whole files — exactly what BitTorrent does for each piece. And because it’s one-way, you can commit to a value publicly without revealing it. Bitcoin leans on both tricks constantly.
Where Bitcoin uses it
Each block of transactions is stamped with the hash of the block before it, so the blocks form an unbreakable chain — change any old transaction and every later hash breaks, and the whole network notices. Mining, as we’ll see, is a race to find an input whose hash starts with a run of zeros. Hashing is the glue and the engine both.
Hashing proves data hasn’t changed. But money also needs to prove WHO authorised a payment — and that requires a different tool: a matched pair of keys, next.
Spotted an error or have feedback on this lesson? Suggest a correction ↗
Comments
Powered by Nostr — reply from any Nostr client, and zap the lesson over Lightning.