Run this project's four from-scratch classical factoring attacks (attacker/classical.py) against a composite number, side by side.
0. How each attack actually works, step by step
try your own composite — every stage below recomputes for real, and the tool below stays in sync
trying every candidate divisor of 8051, one at a time
O(√n) — has to reach 83 before it finds anything
01Check every possible divisor up to √n. Always correct eventually — but painfully slow for large n.
The actual code behind this step
limit = math.isqrt(n)d = 3while d <= limit:operations += 1remainder = n % dif trace is not None:trace.append(TrialDivisionStep(d, remainder, remainder == 0))if remainder == 0:elapsed = time.perf_counter() - startreturn FactorAttemptResult(n, "trial_division", d, n // d, operations, elapsed, True, trace=trace)
1. Run all four attacks live
Using n = 8051 — change above.
Replay: trial division, one divisor at a time
The real attempt log for n = 8051 -- every odd divisor trial division actually tried, in order, not just the final operations count.
Trial division
Tries every divisor up to √n. Fast only when n has a small factor -- O(√n) in general.
Fermat's method
Expresses n = a² − b². Extremely fast when the two prime factors are close together -- a real historical implementation bug class.
Pollard's rho
General-purpose cycle-detection method, expected ~O(n^(1/4)) -- better than trial division for generic composites.
Pollard's p-1
Succeeds fast only when p−1 (or q−1) is "smooth" (all small prime factors) -- defended against by choosing safe primes.
None of these demonstrations scale to real RSA key sizes (2048+ bits) -- see the Classical Benchmark page for measured evidence of the exponential growth.