| Crates.io | diffsquare |
| lib.rs | diffsquare |
| version | 0.9.0 |
| created_at | 2025-05-31 11:56:15.755949+00 |
| updated_at | 2025-06-29 15:07:44.463362+00 |
| description | Fast and efficient Fermat factorization CLI |
| homepage | https://abhrankan-chakrabarti.github.io/diffsquare |
| repository | https://github.com/Abhrankan-Chakrabarti/diffsquare |
| max_upload_size | |
| id | 1696301 |
| size | 56,020 |
Created by Abhrankan Chakrabarti, this project implements an efficient version of Fermatโs Difference of Squares method for factoring large integers. Written in Rust, it leverages the malachite crate for high-performance arbitrary-precision arithmetic.
๐งฎ Persistent interactive mode
diffsquare is run without any flags or piped input, it now enters a continuous interactive loop.exit or quit.diffsquare is a fast and lightweight CLI utility for factoring large integers using Fermatโs Difference of Squares method.
rayon for faster factorization on multi-core systems (since v0.5.0).--input) (new in v0.7.0).--output to save results (since v0.6.0).--threads (new in v0.7.0).--timeout N to limit maximum time per factorization in milliseconds (since v0.6.1).--csv flag (since v0.6.1).--json) for scripting and automation (since v0.3.0).-q) disables prompts and hides intermediate output โ ideal for scripting.--time-only flag for showing only execution time โ useful for benchmarking (since v0.3.1).--stdin (since v0.4.0).--iter) and precision (--prec).GitHub Repository:
diffsquare
Install via Cargo:
cargo install diffsquare
Ensure $HOME/.cargo/bin is in your PATH:
export PATH="$HOME/.cargo/bin:$PATH"
To build from source manually:
git clone https://github.com/Abhrankan-Chakrabarti/diffsquare.git
cd diffsquare
cargo build --release
Run diffsquare interactively or use flags for automation:
# ๐น Fully interactive: prompts for modulus
diffsquare
# ๐น Provide a decimal modulus
diffsquare -n 179769313486231590772930519078902473361797697894230657273430081157732675805505620686985379449212982959585501387537164015710139858647833778606925583497541085196591615128057575940752635007475935288710823649949940771895617054361149474865046711015101563940680527540071584560878577663743040086340742855278549092581
# ๐น Provide a hexadecimal modulus
diffsquare -n 0xDEADBEEFCAFEBABE1234567890
# ๐น Specify starting iteration
diffsquare -n 0xC0FFEE123456789 -i 1000000
# ๐น Use custom precision for verbose scientific output
diffsquare -n 0xABCD1234 -p 30
# ๐น Quiet mode, suppress intermediate output
diffsquare -n 0xCAFED00D1234 -q
# ๐น JSON output for scripting
diffsquare -n 0xC0FFEE123456789 --json
# ๐น Show only execution time (for benchmarking)
diffsquare -n 0xCAFED00D1234 --time-only
# ๐น Factor 2^32 + 1 (Fermat number F5) from piped input
echo "2^32 + 1" | bc | diffsquare
# ๐น Batch factorization from stdin
echo -e "2761929023323646159\n3189046231347719467" | diffsquare --stdin
# ๐น Batch factorization from file input
diffsquare --input numbers.txt
# ๐น Batch with threads and JSON output
diffsquare --input numbers.txt --threads 4 --json
# ๐น Batch with CSV output and save to file
diffsquare --input numbers.txt --csv --output results.csv
| Short | Long | Description |
|---|---|---|
-n |
--mod |
Number to factor (supports 0x for hex or scientific notation) |
-i |
--iter |
Starting iteration value |
-p |
--prec |
Precision for verbose scientific output |
-q |
--quiet |
Suppress prompts and intermediate output |
--json |
Output result in JSON format | |
--csv |
Output result as CSV | |
--time-only |
Show only execution time | |
--stdin |
Read newline-separated input from stdin | |
--input |
Read newline-separated input from file | |
--threads |
Number of threads for batch factorization (--stdin / --input) (default: logical CPUs) |
|
--output |
Output results to file | |
--timeout |
Timeout in milliseconds for each factorization | |
-h |
--help |
Show usage help |
-v |
--version |
Show version |
Tags
#RustLang #NumberTheory #OpenSource #BigInteger #Cryptography #Fermat #AbhrankanChakrabarti #Malachite