RSA Calculator
Explore RSA public-key cryptography step by step. Pick two primes p and q (or generate a fresh pair), choose a public exponent e, and the tool derives the modulus n = pq, Euler's totient φ(n) = (p−1)(q−1), and the private exponent d = e⁻¹ mod φ(n). Then encrypt and decrypt messages (numeric, or short text encoded as a base-256 integer) and sign / verify them — all with exact BigInt modular exponentiation. Everything runs locally in your browser.
Key generation
Encrypt / Decrypt
Sign / Verify
RSA is a public-key cryptosystem. Pick two large primes p and q; the modulus is n = pq. Euler's totient φ(n) = (p−1)(q−1) counts the numbers below n that are coprime to n. Choose a public exponent e coprime to φ(n); the private exponent is d = e⁻¹ mod φ(n) (found with the extended Euclidean algorithm). The public key is (n, e) and the private key is d. To encrypt a message m (an integer with 0 ≤ m < n), compute c = mᵉ mod n; to decrypt, compute m = cᵈ mod n. To sign, compute s = mᵈ mod n; anyone verifies by checking mᵉ mod n equals s — proving only the key holder could have signed. This tool uses exact BigInt arithmetic and Miller-Rabin prime generation; these are toy key sizes for learning, nowhere near real-world security (real RSA uses ≥2048-bit keys). Pairs with the Modular Arithmetic, Euler's Totient, and Prime Factorization tools. Everything runs locally — nothing leaves your browser.