# Hash functions

A hash function turns any data into a short, fixed-size fingerprint, and one changed letter changes it completely. Try it live and see how Bitcoin uses it.

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


## A fingerprint for data
A hash function takes any input (a word, a file, a whole block) and produces a fixed-size output called a **hash** or **digest**. Bitcoin mostly uses [SHA-256](https://mybitcoinexplorer.com/learn/sha-256), whose output is always 256 bits, written as 64 hex characters.

> Diagram: Real SHA-256 hashes: one letter of difference gives an unrelated result — hello | hellp

## Four properties that matter
| Property | What it means | Why Bitcoin needs it |
|---|---|---|
| Deterministic | Same input, same hash, every time | Every node gets the same result |
| Fast to compute | One hash takes microseconds | Checking blocks is cheap |
| One-way | You can't work backwards from a hash | Mining has no shortcut |
| Collision resistant | Finding two inputs with the same hash is infeasible | IDs like the [txid](https://mybitcoinexplorer.com/learn/transaction-id-txid) are unique |

## Try it
> Interactive exercise: [open the lesson](https://mybitcoinexplorer.com/learn/hash-functions).

## Where Bitcoin uses hashes
- **Block IDs** and [Proof of work](https://mybitcoinexplorer.com/learn/proof-of-work)
- **Transaction IDs**
- **[Merkle roots](https://mybitcoinexplorer.com/learn/merkle-root)**
- **Addresses**, via [HASH160](https://mybitcoinexplorer.com/learn/hash160-and-ripemd160)
- **Checksums** that catch typos in addresses


## Everyday uses of hashing
Hashing isn't only for Bitcoin. Websites store hashes of passwords instead of the passwords themselves, and download pages publish file hashes so you can check nothing was tampered with. Bitcoin uses the same idea to make blocks and transactions tamper-evident.

## Hash vs checksum vs encryption
| | Hash | Checksum | Encryption |
|---|---|---|---|
| Purpose | Fingerprint, tamper evidence | Catch accidental typos | Keep data secret |
| Reversible? | No | No | Yes, with the key |
| Resists deliberate attacks? | Yes | Not necessarily | Yes |


## Key takeaways

- A hash function turns any data into a fixed-size fingerprint.
- A tiny change to the input completely changes the hash.
- Hashes can't be reversed, which is what makes mining fair.

## Common questions

### Is hashing the same as encryption?

No. Encryption can be reversed with a key. Hashing is one-way: there's no key to get the input back.

### Can two inputs have the same hash?

Mathematically yes, because inputs are unlimited and outputs aren't, but finding such a pair for SHA-256 is considered infeasible.

### Why are Bitcoin hashes written in hex?

Hex shows each byte as two characters, so a 32-byte hash fits in 64 readable characters.

### Can a hash be decrypted?

No. A hash isn't encrypted data; the original can only be found by guessing inputs.

## Related lessons

- [SHA-256](https://mybitcoinexplorer.com/learn/sha-256)
- [Proof of work](https://mybitcoinexplorer.com/learn/proof-of-work)
- [Merkle trees and the merkle root](https://mybitcoinexplorer.com/learn/merkle-root)
- [HASH160 and RIPEMD-160](https://mybitcoinexplorer.com/learn/hash160-and-ripemd160)
