What is SHA-256?
SHA-256 (Secure Hash Algorithm 256-bit) is a hash function—a mathematical formula that takes any input and produces a fixed-size output. No matter if you input a single letter or an entire library, the output is always exactly 256 bits (64 hexadecimal characters).
Try It Yourself
Type anything below. Watch the hash change instantly. Every input produces a completely different output—even changing a single character transforms the entire result.
Live Hash Generator
Type or paste any text and see its SHA-256 hash in real-time.
The Avalanche Effect
One of SHA-256's most important properties: tiny changes in input cause massive changes in output. This is called the "avalanche effect." Change one letter, one bit, one anything—and roughly half of all output bits flip.
Avalanche Demo
Compare two nearly-identical inputs. Watch how different their hashes are.
One-Way Only
SHA-256 is easy to compute forward but impossible to reverse. Given an input, you can calculate the hash instantly. But given a hash, there's no way to figure out what input produced it—except by guessing.
| Direction | Difficulty | Time |
|---|---|---|
| Input → Hash | ✓ Trivial | Microseconds |
| Hash → Input | ✗ Impossible | Longer than the universe |
This asymmetry is what makes proof of work possible. Miners must guess trillions of inputs to find one that produces a hash meeting certain criteria. But once found, anyone can verify it with a single computation.
Always the Same
SHA-256 is deterministic: the same input always produces the same output. Always. Run it on any computer, any operating system, any time—identical input means identical hash.
Determinism Check
The hash of "Bitcoin" is always:
Try it above. Type exactly "Bitcoin" (capital B) and you'll get this exact hash. Every time. Forever.
Collision Resistance
A "collision" is when two different inputs produce the same hash. With 2²⁵⁶ possible outputs, finding a collision by chance is essentially impossible.
There are more possible SHA-256 outputs than atoms in the observable universe. The odds of accidentally finding two inputs with the same hash are so low that it has never happened and almost certainly never will.
Why Bitcoin Uses SHA-256
Bitcoin uses SHA-256 (actually double SHA-256) for several critical functions:
| Use Case | Why SHA-256 |
|---|---|
| Mining / Proof of Work | Miners hash block headers looking for outputs below a target. The one-way property means they must guess. |
| Block Linking | Each block contains the hash of the previous block. This chains them together immutably. |
| Transaction IDs | Every transaction has a unique ID derived from its hash. Determinism ensures everyone calculates the same ID. |
| Merkle Trees | Transactions in a block are hashed into a tree structure, allowing efficient verification. |
| Address Generation | Public keys are hashed (with other algorithms too) to create Bitcoin addresses. |
Frequently Asked Questions
Can SHA-256 be reversed?
No. SHA-256 is a one-way function. Given a hash, there's no mathematical way to find the original input except by guessing—which would take longer than the age of the universe.
Has anyone found a SHA-256 collision?
No. With 2²⁵⁶ possible outputs (more than atoms in the observable universe), the odds of accidentally finding two inputs with the same hash are essentially zero.
Why does Bitcoin use SHA-256 twice?
Double SHA-256 (hashing the hash) helps prevent length-extension attacks and adds an extra layer of security. It's a simple change that makes the protocol more robust.