RSA Calculator

Calculate the RSA modulus, totient, private exponent, ciphertext, and recovered plaintext from two primes, an exponent, and a message. RSA Calculator helps students, developers, and security professionals understand and test textbook public-key encryption.

Highlights

  • Generate RSA public and private keys from two prime numbers.
  • Calculate the RSA modulus, Euler totient, and private exponent.
  • Encrypt numerical messages using the RSA public key.
  • Decrypt ciphertext to verify the recovered plaintext.
  • Ideal for learning and testing textbook RSA encryption.

Table of Contents

  1. How RSA Calculator Works?
  2. Practical Use Cases
  3. Accuracy and Limitations
  4. Quick Examples
  5. Frequently Asked Questions (FAQs)
  6. Cite This Calculator

How RSA Calculator Works?

The RSA Calculator demonstrates textbook RSA using two prime numbers, a public exponent, and a numerical message. First, it multiplies the primes p and q to produce the RSA modulus n:

n=p×q

It then calculates Euler’s totient, which for two distinct primes is:

φ(n)=(p−1)×(q−1)

The public exponent e must be relatively prime to φ(n), meaning their greatest common divisor is 1. The calculator finds the private exponent d as the modular inverse of e modulo φ(n):

e×d≡1 mod φ(n)

Encryption uses the public key (n, e). For a message m smaller than n, the ciphertext c is calculated as:

c≡me mod n

Decryption applies the private exponent to the ciphertext:

mrecovered≡cd mod n

For example, using the default inputs produces the following results:


QuantityCalculationResult
Modulus n61 × 533233
Totient φ(n)60 × 523120
Private exponent d17−1 modulo 31202753
Ciphertext c6517 modulo 32332790
Recovered message27902753 modulo 323365

The recovery works because the exponents are mathematically related through the totient, allowing modular exponentiation with d to reverse the encryption performed with e.

Practical Use Cases

Students can use the calculator to follow every stage of RSA by hand, from selecting primes and calculating the totient to finding a modular inverse and checking that decryption returns the original message.

Programming learners can compare their implementation of modular exponentiation, greatest-common-divisor checks, and modular inverse calculations with the calculator’s modulus, keys, ciphertext, and recovered plaintext.

Security professionals can use small numerical examples to demonstrate the relationship between RSA’s public and private keys, while emphasizing why real systems require large keys and secure padding schemes.

Cryptography instructors can create classroom exercises by changing p, q, e, and m, then asking learners to predict the outputs before verifying them.

Developers testing educational tools can use the calculator as a reference for validating textbook RSA workflows, including whether a ciphertext decrypts to the original numerical plaintext.

Accuracy and Limitations

The calculator accurately applies textbook RSA integer arithmetic when p and q are distinct primes, the public exponent e is relatively prime to φ(n), and the message m is smaller than n. Its inputs are restricted to integers, with primes and the public exponent limited to 1,000,000 and the message limited to 1,000,000,000. It is an educational model rather than a secure production RSA implementation: it does not provide probabilistic primality testing details, key-size security, message encoding, randomized padding such as OAEP, signature processing, or protection against practical cryptographic attacks. Reusing small primes or the same key for real data is insecure.

Quick Examples

Example #1: Classic RSA Example

Demonstrates RSA key generation and encryption using two small prime numbers.

Example #2: Small Integer Message

Tests RSA encryption with smaller primes and a message below the resulting modulus.

Example #3: Larger RSA Parameters

Illustrates RSA calculations with larger prime factors and a higher public exponent.

Frequently Asked Questions

RSA is a public-key cryptographic system that uses a public key for encryption and a private key for decryption. Its security relies on the difficulty of factoring large numbers.

A public key can be shared openly and is used to encrypt information or verify signatures. A private key must remain secret and is used to decrypt information or create signatures.

The product of two prime numbers forms the RSA modulus, while the primes help define the corresponding private key. Keeping these primes secret is essential for security.

RSA plaintext values must be smaller than the modulus to be processed correctly. Larger data must be divided, encoded, or handled through a hybrid encryption system.

Textbook RSA is useful for learning but should not be used directly in production. Practical systems require secure padding schemes, such as OAEP, and adequately large keys.

Cite This Calculator