FactorDB is a database of numbers that is widely used to check if a certain number is composite or prime.
1. How to use
I generated a number for this page.
from Crypto.Util.number import getPrime
getPrime(8) * getPrime(9) * getPrime(10) * getPrime(12) * getPrime(15)
#=> 2521768789523101
Quite big, isn’t it?
1.1. On Web
When you visit the site, you will see a form with button "Factorize!". You can write a number you want to know to the form, and click "Factorize!".
You will see the number is composite, saying…
status: FF
digits: 16
number: 2521768789523101<16> = 137 路 491 路 571 路 3943 路 16651
And yes, the number is composite, and consist of 5 primes.
When you see status column, you can see "FF". That means the number is Fully Factored.
Since you, readers, are familiar with CTF challenges, you will most likely to see P(Prime), Prp(Probably Prime), and FF.
1.2. Using factordb-rust
You can also install packages to use FactorDB. Since FactorDB website opened APIs to talk with their service, there are lots of programs that can factor primes with FactorDB.
Since many people use Rust and many tools are written in Rust nowadays, you might have cargo in you system.
You can install with cargo, calling…
$ cargo install factordb-rust --all-features
I want to mention again, you should be online. It does not work offline.
$ factordb 2521768789523101
error: factordb: 2521768789523101: Request error: error sending request for url (http://factordb.com/api?query=2521768789523101): error trying to connect: tcp connect error: No route to host (os error 113)
Basic usage is just passing the number as an argument.
$ factordb 2521768789523101
137 491 571 3943 16651
The good thing about these kind of tools is that it can help you automate things.
Let’s pass --json and see what’s going on.
$ factordb 2521768789523101 --json
{"id":"2521768789523101","status":"FF","factors":[["137",1],["491",1],["571",1],["3943",1],["16651",1]]}
That means, you can pass the result to good JSON parser programs. I would like to use jq.
$ factordb 2521768789523101 --json | jq ".status"
"FF"
1.3. Help!
Rust wrapper for FactorDB API
Usage: factordb [OPTIONS] [NUMBERS]...
Arguments:
[NUMBERS]... Number to find its factor
Options:
--unique Print unique factors on each line
--json Print JSON output of FactorDB API
-h, --help Print help
-V, --version Print version