# RSA Calculator

URL: https://speedycalculator.com/calculators/math/rsa/
Last updated: 2026-10-30

> The RSA calculator walks through textbook RSA: from two primes p and q and a public exponent e it computes the modulus N, Carmichael's λ(N), the private exponent d, and encrypts and decrypts a message number.

## Inputs

- Prime p
- Prime q
- Public exponent e
- Message M (number smaller than N)
- Received ciphertext C to decrypt

## Results

- Modulus N = p·q
- λ(N) = lcm(p − 1, q − 1)
- Private exponent d
- Encrypted message Mᵉ mod N
- Decrypted ciphertext Cᵈ mod N

## Formula

```
N = p·q,  λ(N) = lcm(p − 1, q − 1),  d = e⁻¹ mod λ(N)
C = Mᵉ mod N,  M = Cᵈ mod N
```

## Explanation

RSA (Rivest–Shamir–Adleman, 1977) secures web traffic, e-mail and digital signatures. Its security rests on the difficulty of factoring N = p·q when p and q have hundreds of digits. This calculator uses small numbers to show the mechanics.

### How to use the RSA Calculator

- **Prime p**
- **Prime q**
- **Public exponent e**
- **Message M (number smaller than N)**
- **Received ciphertext C to decrypt**

Everything is calculated in your browser, so results appear instantly and nothing you type is sent to a server.

### How it works

Enter two different primes, a public exponent coprime to λ(N) (65537 is standard; small values like 17 work for small primes), a message M smaller than N and a ciphertext C to decrypt. Exact big-integer arithmetic is used.

## Worked example

Inputs — Prime p: 61; Prime q: 53; Public exponent e: 17; Message M (number smaller than N): 65; Received ciphertext C to decrypt: 2,790.

Results — Modulus N = p·q = 3233; λ(N) = lcm(p − 1, q − 1) = 780; **Private exponent d = 413**; Encrypted message Mᵉ mod N = 2790; Decrypted ciphertext Cᵈ mod N = 65.

## Key terms

- **Public key**: (N, e), shared openly.
- **Private key**: d, kept secret.

## FAQ

**Is this secure?**
No – real RSA uses primes of 1,024 bits or more, plus padding.

**Why 65537?**
It is prime, and its binary form 10000000000000001 makes encryption fast.

**What is λ(N)?**
Carmichael's function; φ(N) = (p − 1)(q − 1) also works.

**Why must M be smaller than N?**
Arithmetic is mod N, so larger messages would wrap around.


## Sources

- [Wolfram MathWorld – RSA encryption](https://mathworld.wolfram.com/RSAEncryption.html)
- [Rivest, Shamir, Adleman (1978). A Method for Obtaining Digital Signatures and Public-Key Cryptosystems](https://doi.org/10.1145/359340.359342)
