Explainer · · 6 min read
What it costs to find a SHA-256 prefix
Each extra Base64 character makes the search 64 times longer. Ignoring case makes a letter cost 32 times instead. More threads make guessing faster, not luckier.
1. Guess, hash, compare, repeat
The miner tries numbers in order until a hash starts with your prefix. It joins your phrase and a counter, such as gensys:0. The counter is called the nonce. It hashes the text with SHA-256 and writes the digest in Base64 (message, encoding). Then it compares the first characters with your prefix. A miss is dropped. A hit is hashed again with a reference library before it is reported (main.rs).
gensy with ignore-case was found at nonce 60,237,861 (v2/README.md).2. Why one more character costs 64 times
Each Base64 character is 6 bits, so it has 64 possible values. A hash lands on one given value 1 time in 64. One more exact character therefore means 64 times as many guesses on average.
For a prefix with L letters and D other characters, expected guesses are 32L × 64D, with ignore-case on. With it off, they are 64L+D. Time is guesses divided by hashes per second. Extra threads raise that speed, but not in step: on one shared machine, 6 threads averaged 97 million hashes a second and 11 threads averaged 109, over 3 runs each (earlier runs). They do not lower the guesses.
The miner takes 1 to 10 Base64 characters, or 1 to 16 hex (lib.rs, limits). The cost rule above is also in the README.
3. Try it
Six letters with ignore-case take about 10 seconds. Ten exact characters take centuries. Change the numbers to see the rest.
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.
Ignore-case: all 6 characters are letters.
Where 104.6 comes from. It is the median of a 3-run pilot, not a controlled benchmark: three pinned 6-thread runs of the default backend on one shared i7-8700 (v2/README.md). Unpinned runs gave a median of 87.6 (same file). At 87.6, six letters with ignore-case take about 12 seconds on average, not 10. The pilot does not show how much of the gap comes from pinning. The fast path only covers a message that fits one SHA-256 block (why). Your CPU will differ.
The model. It treats each hash as an independent random draw, which is a good model for SHA-256 and not a proof. It also assumes a steady speed. The miner counts nonces in order, but the hashes look random, so the order does not help. One hit in N tries is expected, and the chance of a hit within N tries is 1 − (1 − 1/N)N, about 63.2% for large N. A real run can finish far sooner or much later than the average.
Nonce limit. Nonces run from 0 to just under 264 (lib.rs). A 10-character exact prefix needs about 260 guesses, 16 times fewer. Running out of nonces first is possible, but the model puts it near 1 in 9 million. A 16-character hex prefix is the hard case: it needs 264 guesses, the whole nonce space, so the model has the miner run out first about 37% of the time. Starting above zero with --start-nonce leaves fewer nonces.
4. Why memory stays small
The miner keeps no list of guesses, only the ranges it has finished. Each thread claims the lowest unfinished chunk, 262,144 nonces by default, and hashes it 128 at a time (chunk size, batch size, claiming). Misses are dropped on the spot.
The journal is appended every half second, and a checkpoint is written every 30 seconds (main.rs). Finished ranges merge when they touch (state.rs). A run with no gaps is one range, however many guesses it has made. Memory does not grow with the number of guesses.
If you stop the miner and rerun it with the same flags, it resumes from the checkpoint and the journal and repeats any unfinished chunk (v2/README.md, resume).
More
- The repository and its v2 notes.
- We made our SHA-256 miner about 42 times faster: the step-by-step explainer, with the measured tests.
The analysis, diagrams and calculator were drafted by ChatGPT (OpenAI GPT-6), then reviewed and edited by Claude. This page describes expected work under a random-hash model. It is not a proof about every way to search SHA-256.