A hash function turns any data into a short, fixed-size fingerprint, and one changed letter changes it completely. Try it live and see how Bitcoin uses it.
A fingerprint for data
A hash function takes any input (a word, a file, a whole block) and produces a fixed-size output called a hash or digest. Bitcoin mostly uses SHA-256, whose output is always 256 bits, written as 64 hex characters.
Four properties that matter
| Property | What it means | Why Bitcoin needs it |
|---|---|---|
| Deterministic | Same input, same hash, every time | Every node gets the same result |
| Fast to compute | One hash takes microseconds | Checking blocks is cheap |
| One-way | You can't work backwards from a hash | Mining has no shortcut |
| Collision resistant | Finding two inputs with the same hash is infeasible | IDs like the txid are unique |
Try it
Where Bitcoin uses hashes
- Block IDs and Proof of work
- Transaction IDs
- Merkle roots
- Addresses, via HASH160
- Checksums that catch typos in addresses
Everyday uses of hashing
Hashing isn't only for Bitcoin. Websites store hashes of passwords instead of the passwords themselves, and download pages publish file hashes so you can check nothing was tampered with. Bitcoin uses the same idea to make blocks and transactions tamper-evident.
Hash vs checksum vs encryption
| Hash | Checksum | Encryption | |
|---|---|---|---|
| Purpose | Fingerprint, tamper evidence | Catch accidental typos | Keep data secret |
| Reversible? | No | No | Yes, with the key |
| Resists deliberate attacks? | Yes | Not necessarily | Yes |
Key takeaways
- A hash function turns any data into a fixed-size fingerprint.
- A tiny change to the input completely changes the hash.
- Hashes can't be reversed, which is what makes mining fair.
Common questions
Is hashing the same as encryption?
No. Encryption can be reversed with a key. Hashing is one-way: there's no key to get the input back.
Can two inputs have the same hash?
Mathematically yes, because inputs are unlimited and outputs aren't, but finding such a pair for SHA-256 is considered infeasible.
Why are Bitcoin hashes written in hex?
Hex shows each byte as two characters, so a 32-byte hash fits in 64 readable characters.
Can a hash be decrypted?
No. A hash isn't encrypted data; the original can only be found by guessing inputs.