SHA-256 is the hash function Bitcoin uses for blocks, transaction IDs and mining, usually applied twice. Learn how it works and test it live.
The basics
SHA-256 (Secure Hash Algorithm, 256-bit) was designed by the US National Security Agency and published by NIST in 2001. It's one of the most studied hash functions in the world, and used far beyond Bitcoin.
- Output: 256 bits = 32 bytes = 64 hex characters.
- Works on 64-byte chunks, mixing them through 64 rounds of bit operations.
Double SHA-256
Bitcoin usually hashes twice, called HASH256:
Used for: block hashes, txids, merkle trees and Base58Check encoding checksums. A widely cited reason is protection against "length extension" weaknesses that affect single SHA-256 in some designs.
See it work
Verify a known hash
The SHA-256 of the text abc is always ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad. Type abc above and check.
How big is 2^256?
SHA-256 has 2^256 possible outputs, a number with 78 digits. If every computer on Earth tried a trillion inputs per second for billions of years, the chance of finding a match for one chosen hash would still be negligible. That's the gap Bitcoin's security relies on.
Where SHA-256 runs in Bitcoin
| Use | Applied |
|---|---|
| Mining and block IDs | Twice, on the 80-byte header |
| Transaction IDs | Twice, on the transaction without witness |
| Merkle trees | Twice, on each pair of hashes |
| Address checksums | Twice, first 4 bytes kept |
| Inside HASH160 | Once, before RIPEMD-160 |
| Taproot tagged hashes | Once, with a tag prefix |
Key takeaways
- SHA-256 produces a 32-byte hash.
- Bitcoin often hashes twice (HASH256).
- It secures block IDs, txids, merkle trees and checksums.
Common questions
Has SHA-256 ever been broken?
No practical attack is known against SHA-256 as used in Bitcoin.
Does mining use double SHA-256?
Yes, miners compute HASH256 of the 80-byte block header.
Is SHA-256 the same as Bitcoin mining?
Mining is the repeated computation of double SHA-256 on block headers, searching for a hash below the target.
Who designed SHA-256?
The US National Security Agency; it was published as a standard by NIST in 2001 and is widely analysed publicly.