Below is a “back–of-the-envelope” way to estimate the brute-force time.
Because the real answer depends on lots of practical details (hash type, file size, hardware, code efficiency), I’ll give you:
- The raw math for 4 unknown bytes.
- Typical hash-rates on today’s hardware.
- Resulting time estimates.
- A few tricks that can make it dramatically faster (incremental hashing, GPUs, rainbow-tables).
────────────────────────────────────────────────────────
- Search-space size
4 bytes = 32 bits
Possible values = 2³² = 4 294 967 296 ≈ 4.3 billion.
On average you only need to test half of them before hitting the right one, so
Expected trials ≈ 2³¹ ≈ 2.15 billion.
────────────────────────────────────────────────────────
2. How fast can you hash?
Rough, real-world single-core rates (short messages, e.g. ≤64 B):
• CRC-32 : 2–4 GB/s (≈6–12 × 10⁸ hashes/s)
• MD5 : 0.5–1 GB/s (≈1.5–3 × 10⁸ hashes/s)
• SHA-1 : 0.3–0.6 GB/s (≈1–2 × 10⁸ hashes/s)
• SHA-256 : 0.15–0.3 GB/s (≈0.5–1 × 10⁸ hashes/s)
Modern GPUs / ASICs (short inputs):
• MD5/SHA-1: 5–20 × 10⁹ hashes/s
• SHA-256 : 0.5–5 × 10⁹ hashes/s
If your file is large and you naïvely recompute the whole hash every time, the rate drops in proportion to the file size. Example: a 10 MB file at 3 GB/s ⇒ only 300 hashes/s!
────────────────────────────────────────────────────────
3. Time estimates (expected, i.e. half the key-space)
Assume the 4 unknown bytes are near the end of the file and you take advantage of incremental hashing so each guess is just one compression round (≈64 B). Table uses the hash-rates above.
| Hash | 1 CPU core | 8-core CPU | Mid-range GPU |
|---|
| CRC-32 @10⁹ h/s | 2.1 s | n/a | n/a |
| MD5 @2 × 10⁸ h/s | 10.7 s | 1.3 s | 0.11 s |
| SHA-1 @1.5 × 10⁸ h/s | 14 s | 1.8 s | 0.15 s |
| SHA-256 @7 × 10⁷ h/s | 30 s | 3.8 s | 0.3–3 s |
If you can’t do incremental hashing and must re-hash a 10 MB file each time at 3 GB/s:
hashes/s ≈ 300
Expected trials 2.15 × 10⁹ / 300 ≈ 8 × 10⁶ s ≈ 93 days ⏳
So the difference between “smart” and “naïve” can be several orders of magnitude.
────────────────────────────────────────────────────────
4. Speed-ups & practical tips
-
Incremental / block hashing
• All widely used hashes (MD5, SHA-*, CRC-32, etc.) process 512- or 1024-bit blocks.
• Pre-compute the digest/state up to the first unknown byte once.
• For each guess you only feed the final block(s), so the hash cost is ~constant, independent of file size.
-
Parallelism
• Every trial is independent → perfect for multicore CPUs, GPUs, clusters, even FPGAs/ASICs.
-
Early-exit / rarity of collisions
• If the checksum is cryptographic, the only way to match is to reproduce the exact original 4 bytes.
• You’re guaranteed a single solution, so once you hit it you can stop.
-
Pre-computation tables (if you need to do this repeatedly)
• 2³² entries = 16 GB (CRC-32) to 128 GB (SHA-256) of storage for a full rainbow table—usually not worth it unless this is a routine task.
────────────────────────────────────────────────────────
Bottom line
• Pure brute force over 4 bytes → 4.3 billion possibilities, ~2.15 billion on average.
• With incremental hashing and a modern desktop CPU/GPU you’re talking seconds to a minute.
• If you have to re-hash a multi-megabyte file for each guess, the time balloons into days or weeks.
Therefore the “how long” ranges from “a coffee break” to “many weeks,” entirely depending on whether you exploit incremental hashing and how much hardware you throw at it.