Crypto Lab

Public key

RSA Demo

Builds tiny public/private keys from two primes, then encrypts a small number.

Public key

Playground

Change inputs and inspect the transformation

RSA uses modular exponentiation and the difficulty of factoring large composite numbers.

Output

Ciphertext

13

Decrypted

7

Steps

Transformation trace

  1. Modulus

    n = 5 x 11 => 55

    The modulus is public and defines the arithmetic space.

  2. Totient

    phi(n) = (5 - 1) x (11 - 1) => 40

    For two primes, phi(n) counts values coprime to n.

  3. Private exponent

    3 x d = 1 mod 40 => 27

    d is the modular inverse of e under phi(n).

  4. Encrypt

    7^3 mod 55 => 13

    The public key is (e, n).

  5. Decrypt

    13^27 mod 55 => 7

    The private key is (d, n).