# SHA-256

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.

Canonical page: https://mybitcoinexplorer.com/learn/sha-256
Topic: Cryptography
Published: 2026-10-29
Updated: 2026-10-30


## 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**:

> Diagram: Bitcoin's double hash — Data → SHA-256 → SHA-256 → *HASH256: 32 bytes

Used for: block hashes, [txids](https://mybitcoinexplorer.com/learn/transaction-id-txid), [merkle trees](https://mybitcoinexplorer.com/learn/merkle-root) and [Base58Check encoding](https://mybitcoinexplorer.com/learn/base58check) checksums. A widely cited reason is protection against "length extension" weaknesses that affect single SHA-256 in some designs.

## See it work
> Interactive exercise: [open the lesson](https://mybitcoinexplorer.com/learn/sha-256).

### Worked example: Verify a known hash
The SHA-256 of the text `abc` is always `ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad`. Type `abc` above and check.


> Is SHA-256 safe from quantum computers? The best known quantum attack (Grover's algorithm) would only halve its effective strength to 128 bits, which is still considered secure. The bigger quantum discussion is about signatures. See [Digital signatures](https://mybitcoinexplorer.com/learn/digital-signatures).


## 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.

## Related lessons

- [Hash functions](https://mybitcoinexplorer.com/learn/hash-functions)
- [Proof of work](https://mybitcoinexplorer.com/learn/proof-of-work)
- [Transaction IDs (txid)](https://mybitcoinexplorer.com/learn/transaction-id-txid)
- [HASH160 and RIPEMD-160](https://mybitcoinexplorer.com/learn/hash160-and-ripemd160)
