RSAbrk is a C program for factoring semiprime numbers, i.e., numbers formed by the product of two large prime numbers (P and Q). It was created for fun and exploration of number theory, and features two different implementations: RSAbrk_v1 and RSAbrk_v2.
You enter a number PQ (assumed to be the product of two primes), and the program attempts to recover P and Q.
- ✅ Version 2 (
RSAbrk_v2) factorsPQ = 124520438789intoP = 128819andQ = 966631in ~17 seconds. - ❌ Version 1 (
RSAbrk_v1) takes 13+ minutes and might still return "no factors found", likely due to precision limitations and inefficiencies in the approach.
“I enjoyed playing with math to come up with this!” — Justus
MRSAbrk.c: Main program entry, asks for user input and prints factor results.RSAbrk.h: Function prototype for the factorization logic.RSAbrk_v1.c: First (slow) algorithm version using mathematical functions and trigonometric exploration.RSAbrk_v2.c: Optimized and more effective second version, refined based on insights from v1.
$ ./MRSAbrk
Entrez pq:
124520438789pq= 124520438789!
n=..., tmp_q=..., ...
124520438789=128819*966631
To compile with either version, change which .c file you link:
gcc MRSAbrk.c RSAbrk_v2.c -o RSAbrk -lmgcc MRSAbrk.c RSAbrk_v1.c -o RSAbrk -lmThe -lm flag links the math library, which is required for sqrt, log10l, etc.
- Uses mathematical transformations and square root approximations to derive possible factors.
- Includes exploratory techniques like applying trigonometric and exponential functions in
v1. v2optimizes the search by bounding the number of iterations using estimates based on the square root ofPQ.
- For large
PQvalues, usev2to avoid long runtimes. - Adjust the precision (
m) and iteration ranges if you plan to extend the algorithm to much larger keys. - This is not suitable for cryptographic-grade RSA keys, but is perfect for educational exploration.