What Is a Hash Function?
A hash function takes any input (text, a file, a block) and produces a fixed-size output called a hash or digest. SHA-256, used by Bitcoin, always gives 256 bits (64 hexadecimal characters).
Important Properties
| Property | Meaning | Why blockchain needs it |
|---|---|---|
| Deterministic | Same input always gives the same hash | Everyone can verify |
| Fast to compute | Easy to hash any data | Practical for nodes |
| One-way | Cannot get the input back from the hash | Hides the data, protects keys |
| Avalanche effect | Tiny change gives a totally different hash | Detects tampering |
| Collision resistant | Practically impossible to find two inputs with the same hash | Hash is a unique fingerprint |
Try It in Python
2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969 64
A Tiny Hash Chain
valid: True after tamper: False
Changing block 2's data breaks its hash, so the chain check fails. This is exactly how real blockchains detect tampering.
Where Blockchains Use Hashes
- Linking blocks (previous hash)
- Merkle trees
- Creating addresses from public keys
- Proof of work puzzles
- Transaction IDs
Practice
- Hash your name and then your name with one extra letter. Compare
- Add a fourth block to the demo chain
- Why is it a problem if two inputs gave the same hash?
Conclusion
A hash is a fixed-size fingerprint. SHA-256 is deterministic, one-way and collision resistant, with an avalanche effect that makes tampering easy to detect.

