Euler Totient for RSA

Enter two primes p and q to compute φ(n), pick a public exponent e, and see the full RSA key generation process step by step.

Inputs

Must satisfy 1 < e < φ(n) and gcd(e, φ(n)) = 1

Quick examples

RSA Key Components

Enter primes above and click Compute.

Totient Derivation

Extended Euclidean Algorithm — finding d

Step a b q = ⌊a/b⌋ r = a mod b s t
Compute to see steps.

What the columns mean

The extended Euclidean algorithm tracks coefficients s and t such that a·s + b·t = gcd(a,b) at every row. When the remainder hits 0, gcd is found. The final t (adjusted to be positive mod φ(n)) is your private exponent d.

Copied!

Summary

Enter two primes p and q to compute φ(n), pick a public exponent e, and see the full RSA key generation process step by step.

How it works

  1. Enter two distinct prime numbers p and q.
  2. The tool computes the RSA modulus n = p × q.
  3. Euler's totient is calculated as φ(n) = (p-1) × (q-1).
  4. A valid public exponent e is chosen: 1 < e < φ(n) with gcd(e, φ(n)) = 1.
  5. The private exponent d = e⁻¹ mod φ(n) is found via the extended Euclidean algorithm.
  6. The step-by-step table shows every division, quotient, and back-substitution used to find d.

Use cases

  • Learn RSA key generation for a cryptography course.
  • Verify hand-computed RSA homework answers.
  • Understand why the extended Euclidean algorithm is used to find d.
  • Debug a custom RSA implementation by checking intermediate values.
  • Explore how small prime choices affect key size and security.
  • Visualize the relationship between p, q, n, φ(n), e, and d.

Frequently Asked Questions

Last updated: 2026-07-08 · Reviewed by Nham Vu