Blockchain Hash Functions
A hash function turns any input into a short code of fixed size. Blockchains use hashes to link blocks, detect changes, and build mining puzzles. Understanding hashes unlocks most of the technology.
What Is a Hash?
A hash is a digital fingerprint of data. You feed a word, a file, or a whole block into the function. The function returns a string of letters and numbers. Bitcoin uses a function called SHA-256, which always returns 64 characters.
Think of a fruit blender. You drop in fruit and get a smoothie. Nobody can turn the smoothie back into fruit. The same fruit in the same amounts always makes the same smoothie.
Input Hash Function Output "hello" → [ SHA-256 ] → 2cf24dba5fb0...938b9824
Key Properties
Deterministic
The same input always gives the same hash. Two people hashing the word "hello" get identical results.
Fixed Length
A single letter and a full movie file both produce a hash of equal length. Short outputs make storage and comparison easy.
One-Way
Nobody can rebuild the original data from its hash. The only option is to guess inputs and compare results.
Avalanche Effect
A tiny change in the input creates a completely different hash. The next section shows this effect.
Collision Resistance
Finding two different inputs with the same hash is practically impossible. This property keeps every fingerprint unique.
Avalanche Effect Example
Compare the SHA-256 hashes of two words that differ by one capital letter.
hello → 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 Hello → 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969
The two results share no visible pattern. A tamperer cannot nudge data and hope for a similar hash.
How Blockchain Uses Hashes
Linking Blocks
Every block stores the hash of the block before it. A change in an old block alters its hash and breaks every link after it.
Block 1 Block 2 Block 3
Hash: A1F3 → Previous: A1F3 → Previous: 7C9D
Hash: 7C9D Hash: 2B8E
Suppose someone edits Block 1. Its hash changes from A1F3 to a new value. Block 2 still holds A1F3, so the mismatch exposes the edit right away.
Mining Puzzles
Miners hash block data again and again with different numbers until the result starts with a required number of zeros. The hard work proves effort and protects the network.
Addresses and Merkle Trees
Wallet addresses come from hashes of public keys. Merkle trees combine hashes of many transactions into one short summary.
Common Hash Functions
| Function | Output Size | Used By |
|---|---|---|
| SHA-256 | 256 bits | Bitcoin blocks and mining |
| RIPEMD-160 | 160 bits | Bitcoin address creation |
| Keccak-256 | 256 bits | Ethereum addresses and data |
Try It Yourself
Open any free online SHA-256 calculator. Type your first name and note the result. Add one extra letter and compare the new hash. The dramatic change shows why blockchain records resist tampering.
Everyday Hash Examples
Hashes appear outside blockchain too. Websites store password hashes instead of the passwords themselves, so a stolen database reveals no readable passwords. Software download pages publish a hash next to each file. Users hash the downloaded file and compare the result to confirm nobody altered it on the way.
Common Mistakes
Many beginners call hashing a form of encryption. Encryption allows decryption with a key. Hashing never allows a reverse step. Another mistake treats a hash as secret data. Anyone can compute a hash, so a hash alone does not hide the input.
