RSA Calculator

By: Calculator Grid

RSA Calculator

Generate an educational RSA key pair, encrypt a numeric message, and verify decryption with exact integer arithmetic.

N 5,963 λ(N) 264 e 17 d 233
Ready with the demonstration values.

RSA parameters and messages

Use small primes for learning. This calculator validates every integer before computing the key relationship.

Required prime integer from 3 to 10,000,000.

Required prime integer, different from p.

Must be less than λ(N) and coprime to it.

Optional nonnegative integer smaller than N.

Optional ciphertext integer from 0 to N – 1.

Live results

Public key (N, e)

(5,963, 17)

Publish both values for this educational example.

Modulus N 5,963

p × q

Carmichael λ(N) 264

lcm(p – 1, q – 1)

Private exponent d 233

e⁻¹ mod λ(N)

Encrypted message C 1,032

Mᵉ mod N

Decrypted message M 1,415

Cᵈ mod N

Public key 5,963 and 17. Private exponent 233.

RSA calculation details

Item Value Role in the calculation
Prime p 89 First private prime factor.
Prime q 67 Second private prime factor.
Modulus N 5,963 Shared modulus in both keys.
Carmichael λ(N) 264 Cycle length used to derive d.
Public exponent e 17 Public exponent used for encryption.
Private exponent d 233 Secret exponent used for decryption.
Message M 1,415 Plaintext numeric message.
Encrypted message C 1,032 Result of Mᵉ mod N.
Received ciphertext C 1,032 Value supplied to the decryption step.
Decrypted message M 1,415 Result of Cᵈ mod N.

The same canonical integer values populate the results, this table, the accessible summary, and the Excel workbook.

How to use the RSA calculator

What this calculator does

This calculator demonstrates the core number theory behind textbook RSA. It multiplies two prime numbers, calculates the Carmichael value for their product, verifies a public exponent, derives the matching private exponent, and optionally performs numeric encryption and decryption. It is useful for studying modular arithmetic, checking hand calculations, preparing a classroom example, or testing a small coding exercise. It does not generate production-grade cryptographic keys, encode text, add secure padding, protect private material, or replace a reviewed cryptographic library. Real systems use much larger primes, approved key-generation processes, and padding schemes specified in standards such as RFC 8017, PKCS #1.

How to calculate

  1. The calculator opens with a complete demonstration: Prime p = 89, Prime q = 67, Public exponent e = 17, Message M = 1,415, and Received encrypted message C = 1,032. The results and a validated example Excel workbook are available immediately.
  2. Replace Prime p and Prime q with two distinct prime integers. Commas are accepted only as standard thousands separators. Decimal values, signs, scientific notation, and ambiguous decimal-comma forms are rejected.
  3. Choose Public exponent e. The selected integer must be greater than 2, smaller than λ(N), and coprime to λ(N). If a selection is incompatible with the primes, the field explains why.
  4. Optionally enter Message M to calculate encryption and Received encrypted message C to calculate decryption. Each must be a nonnegative integer smaller than N.
  5. Read the public key, private exponent, encryption result, decryption result, and the detail table. Select Download Excel to export the current validated state. Select Reset to clear the demonstration and all calculated content; Excel export is then disabled until a complete valid key state is entered again.

Input guide

Prime p and Prime q are required whole numbers between 3 and 10,000,000. Each must pass a primality test and the two values must differ. A realistic learning example is 89 and 67. Larger values increase N and usually produce larger intermediate numbers, but this input range remains intentionally educational. A common mistake is entering an odd composite number, such as 91, and assuming it is prime.

Public exponent e is a required selection: 3, 17, or 65,537. It controls the encryption exponent and must satisfy gcd(e, λ(N)) = 1 as well as 2 < e < λ(N). The example uses 17. A familiar exponent is not automatically valid for every prime pair; changing p or q can make the current selection incompatible.

Message M is optional and accepts a nonnegative integer from 0 through N – 1. The example value is 1,415. It drives the Encrypted message C result through modular exponentiation. Entering M ≥ N is invalid because elementary RSA works on residue classes modulo N. Received encrypted message C is also optional, uses the same range, and drives the Decrypted message M result. Use 1,032 with the example key to recover 1,415.

Output guide and worked example

Public key (N, e) combines the shared modulus and public exponent. Modulus N is the exact product p × q. Carmichael λ(N) is lcm(p – 1, q – 1) and defines the modular cycle used for key inversion. Private exponent d is the exact multiplicative inverse of e modulo λ(N); it must remain secret in a real implementation. Encrypted message C is an exact modular result, not a probability or estimate. Decrypted message M should equal the original message when the supplied ciphertext was generated with the matching public key. A zero message or ciphertext can legitimately produce zero.

N = 89 × 67 = 5,963
λ(N) = lcm(88, 66) = 264
d = 17⁻¹ mod 264 = 233
C = 1,415¹⁷ mod 5,963 = 1,032
M = 1,032²³³ mod 5,963 = 1,415

The RSA calculation details table repeats each canonical value with its role. Its Item column names the parameter or result, Value gives the exact integer, and Role in the calculation explains how that row participates. High or low values are not inherently better in this small demonstration; production security depends on approved key sizes, randomness, padding, implementation quality, and protocol context.

How the RSA key relationship works

The key pair depends on a one-way asymmetry. Multiplying p and q is easy, while recovering large secret prime factors from N is intended to be difficult. The public exponent e and private exponent d are linked by e × d ≡ 1 (mod λ(N)). That congruence is why exponentiating with one key and then the other returns the original residue. The calculator uses exponentiation by squaring, so it never attempts to create the enormous ordinary value Mᵉ before applying the modulus.

For formal guidance on RSA-based key establishment, consult NIST SP 800-56B Revision 2. For digital-signature use cases and approved signature requirements, see the NIST Digital Signature Standard, FIPS 186-5.

Important limitations

This page intentionally uses small integers so the arithmetic is visible and exportable. Textbook RSA is deterministic: the same message and public key produce the same ciphertext. Production encryption therefore requires a defined encoding and randomized padding construction rather than direct use of Mᵉ mod N on raw application data. Small public exponents, repeated primes, predictable primes, missing padding, side-channel leakage, or incorrect validation can all undermine security even when the displayed equations are mathematically correct.

Use this calculator for education and verification only. Do not use its small key values, private exponent, or raw modular operation to protect real credentials, personal data, payments, or confidential communications.