What is a hash? SHA-256 and Keccak-256 explained
The fingerprint that holds every blockchain together. Type into the demo and watch one letter change everything.
A cryptographic hash function turns any input, from one letter to a whole film, into a fixed-size fingerprint. SHA-256, used by Bitcoin, always produces 256 bits (64 hexadecimal characters). The same input always gives the same hash, a tiny change gives a completely different one, and there's no practical way to work backwards from the hash to the input. Ethereum uses a close relative, Keccak-256.
Try it: a live SHA-256 demo
Type anything. The SHA-256 fingerprint updates as you type, worked out by your own browser. Nothing is sent anywhere.
125 of 256 bits differ (48.8%). For unrelated inputs you'd expect about half, 128.
Notice two things. First, "hello" and "Hello" differ by one capital letter, yet their hashes share almost nothing: about half of the 256 bits flip. That's the avalanche effect. Second, the hash is always 64 characters, whether you type one letter or paste a whole page.
What a hash function does
A hash function is a recipe that mixes input data through many rounds of simple operations until the result looks random. A cryptographic hash function must also meet three security promises:
- One-way (preimage resistance): given a hash, you can't find an input that produces it, except by guessing.
- No second match (second-preimage resistance): given one input, you can't find a different input with the same hash.
- No collisions (collision resistance): you can't find any two inputs with the same hash. With 2256 possible outputs, guessing would take longer than the age of the universe on every computer on Earth.
It's also deterministic (everyone computing the hash of the same data gets the same answer) and fast to check, which is why thousands of computers can verify a blockchain independently.
Concrete examples
| Input | Function | Hash (hex) |
|---|---|---|
hello | SHA-256 | 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 |
Hello | SHA-256 | 185f8db32271fe25f561a6fc938b2e264306ec304eda518007d1764826381969 |
hello | Keccak-256 (Ethereum) | 1c8aff950685c2ed4bc3174f3472287b56d9517b9c948127319a09a7a36deac8 |
hello | SHA3-256 (the final NIST standard) | 3338be694f50c5f338814986cdf0686453a888b84f424d792af4b9202398f392 |
The SHA-256 pair differs in 125 of 256 bits. The last two rows matter if you ever write code for Ethereum: Ethereum adopted Keccak before NIST finished the SHA-3 standard, and NIST then changed one padding detail. So Ethereum's "SHA3" is Keccak-256, and it gives different results from the official SHA3-256. (All values on this page were computed when the page was built and checked against Python's hashlib; the Keccak-256 values were checked against published test vectors.)
Where Bitcoin uses hashes
- Linking blocks. Each block header contains the hash of the previous header, so changing an old block breaks every link after it. See what is a blockchain?
- Mining. Miners hash the 80-byte block header twice with SHA-256 ("double SHA-256"), changing a number called the nonce until the result falls below a target. That's proof of work.
- Transaction IDs are double SHA-256 hashes of the transaction data.
- Merkle roots summarize every transaction in a block in one hash (see blocks and transactions).
- Addresses. Older address types hash the public key with SHA-256 and then RIPEMD-160 to make a shorter 20-byte fingerprint.
Where Ethereum uses Keccak-256
- Addresses: an Ethereum address is the last 20 bytes of the Keccak-256 hash of the public key (see public vs. private keys).
- Function selectors: when you call a smart contract, the first 4 bytes of the Keccak-256 hash of the function's name tell it what to run. For a token transfer,
transfer(address,uint256)hashes to a value startinga9059cbb, the prefix you'll see on almost every token transfer in a block explorer. - Transaction and block hashes, and the keys of the giant tree that stores every account's state.
What hashes can't do
- A hash isn't encryption. There's no key and nothing to decrypt. Hashing hides data only if the data is hard to guess.
- Guessable inputs can be found. The SHA-256 of the 4-digit PIN 4821 is
a388f562e286fdf2…, but there are only 10,000 PINs, so anyone can hash them all in a fraction of a second and find the match. The same goes for short passwords and weak "brain wallet" phrases, which is why wallets use long random seed phrases. - A hash proves data hasn't changed, not that it's true. Hash a false record and you get a perfectly valid fingerprint of a false record.
- Algorithms age. SHA-1, once standard, was broken in practice in 2017 when researchers produced two different PDF files with the same SHA-1 hash. No such attack exists against SHA-256 or Keccak-256. Quantum computers would weaken hash functions only modestly (Grover's algorithm roughly halves the effective strength, leaving SHA-256 with about 128-bit security), which is still considered safe.
Frequently asked questions
What does SHA-256 stand for?
Secure Hash Algorithm with a 256-bit output. It's part of the SHA-2 family published by the US National Institute of Standards and Technology (NIST) in 2001–2002 (FIPS 180-2, now specified in FIPS 180-4) and specified in FIPS 180-4.
Can you reverse a hash?
No. A good hash function is one-way. The only way to "reverse" it is to guess inputs until one matches, which only works when the input is short or predictable.
Why does Bitcoin hash twice?
Bitcoin applies SHA-256 twice (double SHA-256) for block and transaction hashes. Satoshi Nakamoto never explained it; the usual explanation is that it guards against a weakness called a length-extension attack that affects single SHA-256 in some uses.
Is Ethereum's Keccak-256 the same as SHA-3?
Not quite. Ethereum uses the original Keccak submission. NIST's final SHA-3 standard changed the padding rule, so SHA3-256 and Keccak-256 give different hashes for the same input.
Does this demo send my text anywhere?
No. It uses your browser's built-in WebCrypto feature, so the hashing happens on your device.
Could two blocks ever have the same hash?
In theory yes, because there are more possible inputs than outputs. In practice nobody has ever found a SHA-256 collision, and the odds of one happening by chance are astronomically small.
Where to next
Sources
- Secure Hash Standard, FIPS 180-4 (NIST)
- SHA-3 Standard, FIPS 202 (NIST)
- Block chain, Bitcoin developer reference
- Ethereum accounts (ethereum.org)
- Contract ABI specification (Solidity docs)
- SHAttered: the first SHA-1 collision (2017)
- Keccak team
Written for beginners and checked against the sources listed. Last reviewed November 4, 2026. This page is educational and is not financial, tax or legal advice. How we write and check pages.