Hash functions in plain words - a data fingerprint that cannot be forged
What a hash function is, its properties, why a blockchain needs it, how keccak256 differs from SHA-256 and where you meet hashes every day.
In this article
A hash function is one of the "bricks" the whole blockchain stands on. It turns any data - a word, a letter, a gigabyte file - into a short string of fixed length. That string is called a hash, or a "fingerprint" of the data.
An example you can check
Take the keccak256 function Ethereum uses and apply it to two nearly identical words:
keccak256("hello") = 0x1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8
keccak256("Hello") = 0x06b3dfaec148fb1bb2b066f10ec285e7c9bf402ab32aa78a5d38e34566810cd2The difference is one capital letter, and the results have nothing in common. The hash length is always the same: 32 bytes, that is 64 hexadecimal characters (plus 0x in front). Whether the input is "hello" or the whole of "War and Peace" does not matter.
Four properties of a good hash
- Determinism. The same data always gives the same hash. You and your counterparty, independently, get the same result.
- The avalanche effect. The slightest change of input changes the hash beyond recognition. So a change of even one comma in a contract is immediately visible.
- One-wayness. You cannot recover the original data from the hash. The only way is to try variants until the hash matches.
- Collision resistance. It is practically impossible to find two different data sets with the same hash, and impossible to "fit" a document to a desired hash.
Where hashes work in a blockchain
- Linking blocks. Each block contains the hash of the previous one (how a blockchain works). Changing an old block means changing its hash and breaking the whole chain after it.
- Addresses. An Ethereum address is the last 20 bytes of the hash of the public key (details).
- Identifiers. A function number in the ABI and an event identifier are the first bytes of the hash of their signature.
- The Merkle tree. Hashes combine into one "root" value that lets you check whether an element belongs to a set (Merkle trees).
- Deal terms. We record in the contract the hash of the document, not the document itself (hash commitment).
SHA-256 and keccak256
There are many hash functions. In blockchains two are most common:
- SHA-256 - used in Bitcoin.
- keccak256 - used in Ethereum.
They are similar in properties but give different results for the same input. Confusing keccak256 with the standardised SHA-3 is a common mistake: they share an ancestor but differ in details, so the hashes do not match. If you check a hash "by hand" in an online calculator, make sure keccak256 is selected.
Everyday examples
- Downloading a file. The download page states the file's hash. You compute the hash yourself and compare: a match means the file was not swapped.
- Passwords. Sites store not the password but its hash (with an addition called a "salt"): a leaked database does not reveal passwords directly.
- Git. A commit number is a hash of its contents.
- Signing documents. What is signed is not the whole document but its hash: faster and more reliable (signatures).
Limits and subtleties
Short predictable data is vulnerable to brute force. An attacker computes the hash of "123456" in a second and compares it with a list. For short or guessable texts a random string, a salt, is added.
A hash does not prove data is truthful. It proves only that it is the same.
Normalisation matters. The "same" text with different line breaks gives different hashes. That is why deal terms are brought to a canonical form before hashing.
What to read next
A hash protects data from swapping, but what proves that the action was performed by the owner? The answer is in the article on public-key cryptography.
Keep reading
- 1 · Basics
Public-key cryptography - how a signature proves it is you
How private and public keys work, where an address comes from, what an ECDSA digital signature is and why a wallet needs no password. With a clear example.
4 min read - 3 · Under the hood
Merkle trees and membership proofs - verifying millions of items with one hash
How a Merkle tree is built, what a root and a proof are, how a contract verifies an element's membership, where this is used and which attacks exist.
4 min read
Mentioned in
- What is a blockchain, in plain words
- Bitcoin vs Ethereum - the difference and why deals are built on Ethereum
- Public-key cryptography - how a signature proves it is you
- Glossary - blockchain, wallets, smart contracts and escrow from A to Z
- ENS - readable names instead of long Ethereum addresses
- Hash commitment: fixing a deal's terms without revealing them
- Use case - selling a domain and digital goods through escrow
- Ethereum accounts and state - EOAs, contracts and the world state
- Signatures in Ethereum - ECDSA, ecrecover, personal_sign and EIP-712
- Storage layout and variable packing in Solidity
- Proxies and upgradeable contracts - delegatecall, UUPS and the price of flexibility
- Merkle trees and membership proofs - verifying millions of items with one hash
- MEV and front-running - who earns from transaction order and how
- HD wallets - how 12 words yield all your keys (BIP-39, BIP-32, BIP-44)
- Foundry for beginners - compiling, tests, fuzzing and a local network
Ready to try it?
Create your first deal in a couple of minutes. The money is locked in a smart contract and paid out by rules you can see in advance.

