Introduction

RSA is one of the most widely used encryption techniques in the modern world. From securing your banking app to keeping your emails private, RSA plays a crucial role in protecting digital communication.

But what exactly is RSA encryption—and why is it such a big deal?

A Brief History

RSA stands for Rivest–Shamir–Adleman, named after the three MIT cryptographers who introduced the algorithm in 1977.

Before RSA, secure communication over an open network was nearly impossible without first exchanging a shared secret. RSA was revolutionary—it introduced public-key cryptography, allowing two people to exchange encrypted messages without having ever met or shared a key beforehand.

How RSA Encryption Works

RSA is built on three core mathematical concepts:

RSA Algorithm (Step-by-Step)

  1. Choose two large prime numbers: p and q
  2. Compute the modulus:
    $$n = p \times q$$
  3. Compute Euler’s totient function:
    $$\phi(n) = (p - 1)(q - 1)$$
  4. Choose an encryption exponent e such that:
    $$1 < e < \phi(n), \quad \gcd(e, \phi(n)) = 1$$
  5. Determine the decryption key d such that:
    $$d \cdot e \equiv 1 \pmod{\phi(n)}$$

The public key is:
$$ (e, n) $$

The private key is:
$$ (d, n) $$

Encryption:

$$c = m^e \text{ (mod n)}$$

Decryption:

$$m = c^d \text{ (mod n)}$$

Example: RSA with p = 3, q = 11

Let’s walk through a basic example with small numbers (not secure in practice, but great for understanding):

$$ \begin{align*} p &= 3 \\ q &= 11 \\ n &= p \times q = 3 \times 11 = 33 \\ \phi(n) &= (3 - 1)(11 - 1) = 2 \times 10 = 20 \\ e &= 3 \quad (\text{coprime with } 20) \\ d &= 7 \quad (\text{since } 3 \cdot 7 = 21 \equiv 1 \mod 20) \end{align*} $$

Public key: (3, 33)
Private key: (7, 33)

Encrypt message m = 4:

$$ c = 4^3 \text{ (mod 33)} = 64 \text{ (mod 33)} = 31 \text{ (mod 33)}$$

Decrypt ciphertext c = 31:

$$ m = 31^7 \text{ (mod 33)} = 4 \text{ (mod 33)} $$

Success! We recovered the original message.

Real-World Applications of RSA

RSA is used in many applications requiring secure communication:

Click here to try live demo for RSA Enryption.

Conclusion

RSA combines elegant mathematics with practical security. While newer methods like elliptic curve cryptography (ECC) are gaining traction, RSA remains a cornerstone of cybersecurity and a must-know for developers and cryptography enthusiasts alike.