Crates.io | fator-semiprime |
lib.rs | fator-semiprime |
version | 0.1.0 |
source | src |
created_at | 2023-01-06 23:10:15.677194 |
updated_at | 2023-01-06 23:10:15.677194 |
description | An implementation of the Pollard's rho algorithm for factoring semiprime numbers |
homepage | |
repository | |
max_upload_size | |
id | 752663 |
size | 6,606 |
An implementation of the Pollard's rho algorithm for factoring semiprime numbers
Semiprimes (the product of two primes) are much used in cryptography, because multiplying huge primes is waaay faster than factoring the result. This repository contains an algorithm that attempts to do the hard part: factor huge semiprimes.
$ cargo build --release
$ echo 18851959175571007 | ./target/release/factor-semiprime
18851959175571007 = 160097647 * 117752881
You can use Symja or Mathics to generate random primes and multiply them. Here is a code example that works on both projects:
(* Replace the range bellow with the desired range *)
r := RandomPrime[{10^8, 10^9}];
(* p is a pair of two random primes *)
p = {r, r};
(* Print the primes *)
Print[p];
(* Print the product of the two random primes *)
Print[Times @@ p];
$ time echo 437 | ./target/release/fator-semiprime
437 = 23 * 19
real 0m0.008s
user 0m0.003s
sys 0m0.007s
$ time echo 64786756484626223 | ./target/release/fator-semiprime
64786756484626223 = 222522227 * 291147349
real 0m0.026s
user 0m0.026s
sys 0m0.002s
$