RSA Mathematics Calculator
Compute small educational RSA values: n, phi, public/private exponents, encryption, and decryption. This educational calculator shows the formula, result, and step-by-step interpretation.
Calculator
What this calculator teaches
RSA math is built from modular exponentiation, Euler totients, and modular inverses.
Use the result as a learning aid. For classwork, still show the formula and intermediate reasoning so the final answer is not just a black-box number.
The Mathematics Behind RSA
RSA is a public-key cryptosystem built from modular arithmetic. In the textbook construction, choose two distinct primes p and q, form n=pq, and compute φ(n)=(p−1)(q−1). Choose a public exponent e satisfying gcd(e,φ(n))=1, then find the private exponent d such that ed≡1 (mod φ(n)).
A small integer message m is encrypted as c=mᵉ mod n and decrypted as m=cᵈ mod n. The modular inverse relation between e and d is what makes the round trip work under the assumptions of textbook RSA. Practical systems use much larger primes and standardized padding; raw textbook RSA should not be used directly to protect real data.
| Stage | Formula |
|---|---|
| Modulus | n=pq |
| Totient | φ(n)=(p−1)(q−1) |
| Key relation | ed≡1 (mod φ(n)) |
| Encrypt / decrypt | c=mᵉ mod n; m=cᵈ mod n |
For educational inputs, verify that p and q really are prime, that e is coprime to φ(n), and that the message is represented as an integer in the allowed range, typically 0≤m<n. Reusing tiny primes is insecure; the page is designed only to illustrate the number theory.
How to verify a small RSA exercise. First check that p and q are distinct primes. Then compute n and φ(n), confirm gcd(e,φ)=1, and verify that e·d leaves remainder 1 when divided by φ. Finally, encrypt the message and decrypt the ciphertext; the recovered residue should match the original message modulo n.
For hand calculations, repeated squaring is far safer than constructing mᵉ or cᵈ directly. The same fast modular-exponentiation method used elsewhere on CalcNovaHub keeps intermediate numbers small. Remember that this is textbook number theory: real applications additionally need secure key sizes, protected private-key operations, and standardized encoding and padding to resist attacks.
Formula & Symbols
| Concept | Formula or rule |
|---|---|
| Modulus | n = pq |
| Totient | φ(n) = (p-1)(q-1) |
| Private exponent | d ≡ e⁻¹ mod φ(n) |
Worked example
Common mistakes
Keep lists comma separated, matrices as rows separated by semicolons, and modular inputs as integers.
Some methods require positive probabilities, valid moduli, independent trials, or small educational input sizes.
The textbook φ(n)=(p−1)(q−1) formula assumes p and q are prime.
A modular inverse d exists only when gcd(e,φ(n))=1.
FAQ
Related calculators
These links will work after the calculators are registered in the final Math layout update.
Formula Explorer connections
Interpretation: This formula uses integer divisibility, modular arithmetic, finite fields or coding relationships. Assumption: Inputs are usually integers with specific modulus or coprimality requirements. Cryptographic examples are educational and not a substitute for vetted security libraries.