primitive · 02 / 03SHA-256

Hashing

A one-way fingerprint — fixed size, no way back.

What it does

A hash takes any input — one character or a terabyte — and returns a fixed-size fingerprint. SHA-256 — the Secure Hash Algorithm, 256-bit variant — always gives back 256 bits, written as 64 hex characters. Same input, same fingerprint, every time. Any difference at all, a completely different fingerprint.

And it only goes one way. There is no un-hash. Given a fingerprint you can't compute the input it came from — you can only guess inputs and check. The rest of this page is about why that's true, not just asserted.

Why you can't reverse it — 1: it throws information away

The input space is unlimited. There are infinitely many possible messages. The output space is fixed: exactly 2256 fingerprints. You can't map infinitely many things onto finitely many things without sending huge numbers of inputs to the same output. That's the pigeonhole principle, and it guarantees collisions must exist.

So a fingerprint genuinely doesn't identify one input. The information that told two messages apart isn't encrypted — it's simply gone. Here's the same collapse at toy scale, h(n) = n mod 12:

h(n) = n mod 12 = 3

12 possible outputs

0
1
2
3
4
5
6
7
8
9
10
11

inputs that all land on 3

3·15·27·39·51·63·75·87· …forever

Going forward is one cheap division. Going back is impossible: the output 3 came from one of infinitely many inputs, and nothing in it says which. SHA-256 is the same move at absurd scale — every input, of any length, crushed onto one of 2256 outputs.

Why you can't reverse it — 2: it scrambles past algebra

Collapsing the space isn't enough on its own — mod 12 still leaks structure (you learn the input's remainder). SHA-256 also mixes. It runs 64 rounds of additions, bit-rotations, XORs, and bitwise choose/majority functions, folding every input bit into the entire 256-bit state over and over.

The result has no usable algebraic structure to invert. You can't isolate the input and “solve for it,” because each output bit depends on all the input bits through a tangle of non-linear steps. This is what the avalanche effect looks like from the outside — flip one input bit and about half the output bits flip, unpredictably:

worked example · one letter changed

sha-256 digest
cat

cot

Output bits changed0.0%

0 of 256 bits flipped — about half, with no pattern. The hex view lights whole 4-bit digits, so more look changed than bits actually flipped — switch to to count the real ones.

now you — edit a single character

compared against the same text with its last character bumped by one

sha-256 digest
The quick brown fox

The quick brown foy

Output bits changed0.0%

0 of 256 bits flipped — about half, with no pattern. The hex view lights whole 4-bit digits, so more look changed than bits actually flipped — switch to to count the real ones.

Why you can't reverse it — 3: no shortcut, and the space is absurd

Because there's no inverse and no structure to exploit, the only way back is to guess inputs and hash them until one matches — finding a preimage. That means searching a space of 2256 ≈ 1.16 × 1077values. For scale, that's within a few orders of magnitude of the number of atoms in the observable universe.

Put a machine on it doing a trillion hashes a second, then a billion of those machines. Run them since the Big Bang. You'd cover such a vanishing sliver of 2256that the entire age of the universe rounds to zero progress. “Irreversible” here isn't a slogan — it's an arithmetic wall.

What it's for

  • Passwords — a site stores the hash, never the password, with a per-user salt mixed in so identical passwords don't share a fingerprint.
  • File integrity — a published checksum lets you confirm a download arrived byte-for-byte intact.
  • Signatures & blockchains — you sign the hash of a document, and any later edit changes the hash, so tampering is obvious.

A hash isn't locked — it's destroyed on purpose

Encryption hides data behind a key you can later use to get it back. A hash keeps nothing back to recover. There's no key and no return path by design. The moment you need the original data again, you wanted encryption, not SHA-256.