If blockchains have a single building block, it is the cryptographic hash function. It links each block to the one before it, powers Bitcoin mining, creates addresses and lets anyone prove a file has not been altered. Yet the idea behind it is surprisingly simple: take any amount of data and turn it into a short, fixed-length fingerprint.
What a Hash Function Does
A hash function takes an input of any size, a word, a book or a whole block of transactions, and produces an output of fixed length called a hash or digest. Bitcoin’s main function, SHA-256, always outputs 256 bits, shown as 64 hexadecimal characters, no matter how big the input is.
Change a single character in the input, even swapping a full stop for a comma, and the output changes completely and unpredictably. This is called the avalanche effect, and it is what makes hashes useful as fingerprints.
The Properties That Make It “Cryptographic”
| Property | What it means | Why it matters |
|---|---|---|
| Deterministic | The same input always gives the same hash | Anyone can re-check a hash independently |
| Fast to compute | Hashing data is quick | Nodes can verify blocks efficiently |
| Pre-image resistance | You cannot work backwards from a hash to the input | Hashes reveal nothing about the data |
| Collision resistance | It is infeasible to find two inputs with the same hash | Fingerprints are unique in practice |
| Avalanche effect | Tiny input changes produce totally different outputs | Tampering is obvious |
How Hashing Links the Blockchain
Each block header contains the hash of the previous block’s header. That is what makes it a chain. If someone changed a transaction in an old block, that block’s hash would change, which would break the link stored in the next block, and the next, all the way to the tip. To hide the change they would have to recompute every following block, which on a proof-of-work chain means redoing all that mining work.
Inside each block, transactions are hashed in pairs, and those hashes are hashed again, until a single Merkle root remains. It sits in the block header and lets a lightweight wallet confirm a transaction is in a block without downloading every other transaction.
Hashing and Mining
Bitcoin mining is a search for a hash. Miners repeatedly change a small field called the nonce and hash the block header until the result falls below the network’s target, which in practice means it starts with a long run of zeros. Because outputs are unpredictable, there is no clever shortcut; the only way is to try enormous numbers of guesses. The difficulty of that search is what makes the chain costly to rewrite.
Other Places Hashes Appear
- Addresses: Bitcoin and Ethereum addresses are derived by hashing public keys, which shortens them and adds a layer of protection.
- Transaction IDs: every transaction is identified by its hash.
- Proof of existence: projects anchor a document’s hash on-chain to prove it existed unchanged at a certain time.
- Commit-reveal schemes: users can commit to a choice by publishing its hash, then reveal it later.
Common Hash Functions in Crypto
- SHA-256: Bitcoin mining, transaction IDs and block hashes.
- RIPEMD-160: combined with SHA-256 to create shorter Bitcoin addresses.
- Keccak-256: Ethereum’s main hash, used for addresses and contract storage.
- BLAKE2 and BLAKE3: fast modern functions used by several newer networks.
Can Hashes Be Broken?
Older functions like MD5 and SHA-1 have known collision attacks and are no longer considered safe for security. SHA-256 and Keccak-256 have no practical attacks known today. Quantum computers are more of a concern for the digital signatures blockchains use than for hash functions, which are expected to stay strong with modest adjustments.
Key Takeaways
- A hash function turns any data into a fixed-length fingerprint.
- Small input changes produce completely different outputs, making tampering easy to detect.
- Hashes chain blocks together, build Merkle trees, power mining and create addresses.
- Modern hash functions like SHA-256 have no known practical attacks.
Frequently Asked Questions
Is hashing the same as encryption?
No. Encryption is designed to be reversed with a key. Hashing is one-way: you cannot recover the original data from the hash.
Can I hash a file myself?
Yes. Most operating systems include tools to calculate a SHA-256 hash, which is also how software downloads are often verified.
Why does Bitcoin hash data twice?
Bitcoin applies SHA-256 twice in many places. It was a cautious design choice to guard against certain theoretical attacks on single hashing.



