Skip to content
Abhrankan-Chakrabarti

Abhrankan-Chakrabarti/diffsquare

CLILive in production

Fast and efficient Fermat factorization CLI

Fast and efficient Fermat factorization CLI

2 1RustPush 11mo agoListed 14d agoMIT

abhrankan-chakrabarti.github.io/diffsquare/

algorithmsbenchmarkbigintbigintegerclicli-toolcommand-line-utilitiescryptography
  • Rust100.0%
View on GitHub

Report a problem

1 Review

diffsquare is a focused and useful Rust CLI for a narrow problem: Fermat-style integer factorization with big integer support. What stood out most is that it is not just a toy implementation wrapped in a README. The crate has a clean split between the reusable library surface (factor, sqrt, legendre) and the CLI layer, and the command-line interface has clearly been shaped around real usage: decimal/hex/scientific input, quiet mode, JSON/CSV output, stdin and file batch modes, output files, configurable batch threads, progress bars, and per-factorization timeout support. That makes it approachable both for someone experimenting with number theory and for someone who wants to script it into benchmark or teaching workflows.

The README is unusually complete for a small math utility. It gives installation through Cargo, source build instructions, a practical flag table, and examples that cover interactive use, piped input, batch files, JSON, CSV, and benchmarking. The Cargo metadata is also in good shape: MIT license, repository/homepage links, relevant keywords, and docs.rs publication. The test suite is modest but meaningful: it checks known factors, prime and 1 behavior, several larger semiprime examples, square detection, and Legendre table invariants. That gives users some confidence that the core math helpers are being exercised rather than only the CLI happy path.

The biggest improvement I would suggest is documenting the algorithm’s limits more explicitly. Fermat factorization is excellent when factors are close together, but it can be a poor fit for arbitrary RSA-like semiprimes with widely separated factors. A short “when this works well / when it will struggle” section, with example timings for close-factor and far-factor inputs, would help users set expectations and avoid interpreting timeouts as bugs. I would also consider adding CI if it is not already present, plus a few command-level integration tests that run the binary with --json, --csv, --stdin, invalid input, and timeout cases. The current core tests are valuable, but the CLI has enough behavior now that regressions could easily happen in formatting, batch output, or quiet mode.

Overall, diffsquare feels like a compact, well-packaged crate with a clear educational and scripting niche. The project’s small community footprint is expected for a specialized number-theory tool, but the release history, docs.rs presence, MIT license, and practical CLI polish make it much easier to trust and try than many small algorithm demos.