Explainer · · 6 min read

What it costs to find a SHA-256 prefix

64 times as many guesses on average for each extra Base64 character. That drops to 32 times for a letter if you ignore case.

1. Guess, hash, compare, repeat

The miner runs SHA-256 on a phrase and counter, such as gensys:0. It checks the Base64 digest for your prefix and verifies each match with a reference library. The counter is called the nonce.

Four guesses, one match Four columns. Each shows a guess, gensys:0 to gensys:3, with an arrow down to its result. The first three results read no match. The fourth reads match. gensys:0 ✗ no match gensys:1 ✗ no match gensys:2 ✗ no match gensys:3 ✓ match hash each guess, compare the start, keep or drop
Made-up run: nonce 3 is not a real match. A real one: prefix gensy with ignore-case was found at nonce 60,237,861 (v2/README.md).

2. Guesses per character

A Base64 character holds 6 bits. Each guess has a 1 in 64 chance of matching an exact character.

Work added by one more prefix character One more character multiplies the expected guesses by 64 for an exact character, by 32 for a letter when case is ignored, and by 64 for a digit, plus or slash even when case is ignored. One more character in the prefix × 64exact case: any character × 32ignore case: a letter (A and a both count) × 64ignore case: a digit, + or /
Ignore-case is a Base64 option only. Hex prefixes are lowercase and cost 16 times per character.

Time is expected guesses divided by hashes per second. Extra threads raise that speed without changing the number of guesses needed.

Formula, thread counts and prefix limits

For L letters and D other characters, expect 32L × 64D guesses ignoring case, or 64L+D in exact case.

On one shared machine, speed rose by less than the thread count. With 6 threads the miner averaged 97 million hashes a second, and with 11 it averaged 109 million. Each setting ran 3 times.

The miner takes 1 to 10 Base64 characters or 1 to 16 hex characters.

3. Calculator

About 10 seconds on average for six letters ignoring case at the default speed. Ten exact characters take centuries.

Pick a length, a mode and a speed. The answers update as you type.

The controls need JavaScript. The answers below are the default: 6 letters, ignore-case, 104.6 million hashes per second.

Expected guesses1,073,741,824
Expected time10.27 seconds
Chance of a hit by then63.2%

Ignore-case: all 6 characters are letters.

Default speed and assumptions

The 104.6 default is the median of a 3-run pilot with the default backend and 6 pinned threads on a shared i7-8700. The unpinned median of 87.6 gives about 12 seconds for six letters ignoring case. The tests did not isolate pinning.

The fast path needs a message that fits one SHA-256 block. Speed depends on the CPU.

The model assumes a steady speed and independent random hashes, so trying counters in sequence does not improve the odds. For N expected guesses, the chance of a hit by then is 1 − (1 − 1/N)N, about 63.2% for large N. Runs can finish much sooner or later than the average.

Nonce limit

Nonces run from 0 to just under 264. Starting above zero with --start-nonce leaves fewer guesses.

A 10-character exact Base64 prefix needs about 260 guesses, 16 times fewer than the full nonce space. The chance of running out is about 1 in 9 million.

A 16-character hex prefix needs 264 guesses on average. The chance of running out is about 37%.

4. Memory use

The miner discards misses and keeps only finished ranges, so memory does not grow with the number of guesses.

Threads, chunks and the record of finished ranges Three thread boxes, labelled thread 1, thread 2 and thread N, each take one chunk of 262,144 nonces. Misses are discarded. Only finished chunks flow down into a journal of finished ranges, with a checkpoint every 30 seconds. thread 1 thread 2 thread N one chunk each: 262,144 nonces hash, compare, drop every miss finished chunks only journal of finished ranges neighbouring ranges merge into one checkpoint every 30 s
Only the bottom box is kept, and a chunk that was cut short or holds a hit is not recorded.
Batches, checkpoints and resume

Each thread claims the lowest unfinished chunk and hashes 128 nonces at a time. The journal updates every half second. Finished ranges merge when they touch, so a run without gaps keeps one range.

Rerun with the same flags to resume from the checkpoint and journal. The miner repeats any unfinished chunk.

Sources and credits

Code and benchmark references

The analysis, diagrams and calculator were drafted by ChatGPT (OpenAI GPT-6), then reviewed and edited by Claude.

Share on X