RSA Calculator

Generate RSA keys and perform encryption/decryption using the RSA cryptographic algorithm

RSA Key Generation

Common values: 3, 17, 65537. Must be coprime with λ(N)

Generated RSA Keys

Calculated Values

N = p × q =
λ(N) = lcm(p-1, q-1) =
Private exponent d =

Key Components

Public Key: (N=, e=65537)
Private Key: (N=, d=)
⚠️ Invalid parameters

Encryption & Decryption

Encryption

Encrypted Message

C =
Formula: C = Me mod N

Decryption

Decrypted Message

M =
Formula: M = Cd mod N

RSA Algorithm Steps

1

Choose Primes

Select two prime numbers p and q

2

Calculate N

N = p × q (modulus)

3

Find λ(N)

λ(N) = lcm(p-1, q-1)

4

Choose e

Public exponent coprime to λ(N)

5

Calculate d

Private exponent: d ≡ e⁻¹ (mod λ(N))

Example Calculation

Given:

p = 89, q = 67
e = 17

Results:

N = 89 × 67 = 5,963
λ(N) = lcm(88, 66) = 264
d = 233

Encryption Example:

Message: M = 1415
Encrypted: C = 1415¹⁷ mod 5963 = 1032

Security Notes

⚠️

Use large prime numbers in practice (1024+ bits)

⚠️

This calculator is for educational purposes only

ℹ️

RSA security relies on difficulty of factoring large numbers

Modern RSA uses 2048-bit or 4096-bit keys

Understanding the RSA Algorithm

What is RSA?

RSA (Rivest-Shamir-Adleman) is an asymmetric cryptographic algorithm published in 1977. It uses a pair of mathematically related keys: a public key for encryption and a private key for decryption.

Key Components

  • N: Modulus (product of two primes)
  • e: Public exponent (encryption key)
  • d: Private exponent (decryption key)
  • λ(N): Carmichael function of N

Mathematical Foundation

Key Generation:

1. Choose primes p, q
2. N = p × q
3. λ(N) = lcm(p-1, q-1)
4. Choose e: gcd(e, λ(N)) = 1
5. d ≡ e⁻¹ (mod λ(N))

Encryption/Decryption:

Encrypt: C ≡ M^e (mod N)
Decrypt: M ≡ C^d (mod N)

Security Considerations

Strengths

  • • Mathematically proven security
  • • Based on prime factorization difficulty
  • • Widely adopted and tested
  • • Enables digital signatures

Considerations

  • • Requires large key sizes (2048+ bits)
  • • Vulnerable to quantum computers
  • • Padding schemes needed for security
  • • Slower than symmetric encryption