A React + TypeScript toolkit of calculators for modular number theory and common cryptography tasks. Made for convenience and for reinforcing concepts from a Master’s cryptography course.
https://zamilbahri.github.io/mod-calculator-suite
-
RSA Calculator
- Supports RSA encryption/decryption with configurable key inputs and key derivation tools.
- Implemented encoding modes:
- Direct Integer
- Fixed-width numeric slicing
- Radix (b-adic) packing
- PKCS#1 v1.5 padding
- Includes a Recover primes decryption option for moduli where
N < 2^72.- Prime recovery is multithreaded and uses up to two web workers.
- Before worker scans begin, divisibility is prechecked for small prime factors up to and including
997. - For an
n-bit RSA modulusN, the worker ranges are split as:balanced: frommax(nextPrimeAfterPrecheck, 2^(floor(n/2)-1))(inclusive) tofloor(sqrt(N)) + 1(exclusive), wherenextPrimeAfterPrecheckis currently1009.low: fromnextPrimeAfterPrecheck(inclusive) tomax(nextPrimeAfterPrecheck, 2^(floor(n/2)-1))(exclusive).
-
Prime Generator
- Generates probable primes by bit size or digit size.
- Supports generation of up to 10 primes, with count limits by size policy:
Max Prime Size (bits) Max Count Warning Starts At 1536 10 11 (No warning) 2048 10 5 3072 4 2 4096 4 1 - Prime generation is multithreaded, and the user can set the number of worker threads.
-
Prime Checker
- Uses Baillie-PSW and Miller-Rabin primality testing.
- For
n < 2^64, Baillie-PSW is used. - For larger values, Miller-Rabin is used with a default of 24 rounds.
- The user can configure the number of Miller-Rabin rounds.
-
EGCD and Modular Inverse Calculator
- Computes
gcd(a, b), Bézout coefficients, and modular inverses.
- Computes
-
Fast Exponentiation
- Computes
a^n mod musing square-and-multiply.
- Computes
-
CRT Solver
- Solves systems of congruences with pairwise coprime moduli.
-
Matrix Modular Determinant, RREF, and Inverse Calculator
- Normalizes a matrix
A mod m, and computesdet(A) mod m,RREF(A) mod m, andA^-1 mod m.
- Normalizes a matrix
-
Matrix Multiplcation Caluclator
- Calculates the product of two matrices
A x B mod m.
- Calculates the product of two matrices
-
Polynomial Arithmetic over GF(2)
- Supports addition, multiplication, division, and remainder for polynomials in
$GF(2)$ .
- Supports addition, multiplication, division, and remainder for polynomials in
-
Polynomial GCD over GF(2)
- Computes the Greatest Common Divisor (GCD) using the Euclidean algorithm.
-
Polynomial Inverse over GF(2)
- Computes modular inverses using the Extended Euclidean Algorithm (EEA) with steps.
- Node.js 20+
- npm
npm installnpm run devnpm run buildThis project is licensed under the MIT License - see the LICENSE file for details.