> HASH PREFIX CIPHER
The idea in plain English: A hash function is like a meat grinder — you put any input in (a word, a sentence, anything), and it grinds it into a fixed-length output that looks random. The output (called a "hash") is always the same for the same input, but even a tiny change in the input produces a completely different hash. This puzzle gives you a prefix — a few hex characters like "e7b0" — and you need to find a string whose hash starts with those characters. The only way is to try strings until you find one that works: "aaaaaa", "aaaaab", "aaaaac"... until you get lucky.
Why this really exists: This is exactly how Bitcoin mining works! Bitcoin miners try billions of inputs per second looking for a hash starting with a certain number of zeros. The more zeros required, the harder it is (and the more computing power you need). This is called proof-of-work, and it's also how email spam filters work (Hashcash) — you prove you spent computing effort before sending an email.
▸ Concrete Example
Prefix to find: "e7b0" (that's 4 hex chars = 16 bits)
SHA-256("aaaaab") = f4e2a1... → starts with "f4e2" — no
SHA-256("aaaaac") = 7c3d9f... → starts with "7c3d" — no
...keep trying...
SHA-256("abd3k7") = e7b02a... → starts with "e7b0" — YES!
Answer: "abd3k7" (takes ~65,000 tries on average for 16-bit prefix)
The longer the prefix, the harder it gets. Each extra hex character multiplies the difficulty by 16.
▸ How to Solve (Step by Step)
1. Read the target prefix from the puzzle data
2. Start with a counter = 0 (or any starting string)
3. Compute SHA-256 of the counter as a string
4. Convert the hash to hex — check if it starts with the prefix
5. If yes: submit that counter as the answer. If no: increment the counter and repeat
prefix = "e7b0"
counter = 0
while True:
h = hashlib.sha256(str(counter).encode()).hexdigest()
if h.startswith(prefix):
print(f"Found: {counter}")
break
counter += 1
⚠️ In the website, the prefix is capped at 4 hex chars (16 bits) to keep it solvable in under 60 seconds. A longer prefix would take hours on a CPU.
▸ Difficulty Table
| Hex chars | Bits | Avg attempts | Time (CPU) |
|---|---|---|---|
| 2 | 8 | ~256 | instant |
| 3 | 12 | ~4,096 | ~0.1s |
| 4 | 16 | ~65,536 | ~1-5s |
| 5 | 20 | ~1 million | ~30s |
| 6 | 24 | ~16 million | ~8 min |
▸ Real-World Applications
- Bitcoin: Miners find hashes with many leading zeros to add blocks to the blockchain
- Hashcash: Anti-spam system — you attach a proof-of-work stamp to each email
- Password storage: Websites hash your password (with salt) so even if hacked, the original password is hidden
- File integrity: Downloads include SHA-256 checksums so you can verify the file wasn't corrupted