In today’s digital world, safeguarding sensitive information is more critical than ever. Whether online banking, secure emails, or encrypted messages, RSA encryption plays a vital role in protecting our data. As one of the most widely used public-key cryptosystems, RSA ensures confidentiality, integrity, and authenticity across countless applications.

The Power of Asymmetric Cryptography
RSA operates on asymmetric encryption, meaning it uses two mathematically linked keys:
✅ A public key for encryption (shared freely)
✅ A private key for decryption (kept secret)

This approach eliminates the need for pre-shared secrets, making secure communication simpler and more scalable.

How RSA Encryption Works: A Step-by-Step Breakdown

  1. Key Generation: The Security Foundation 🔹 Selecting Prime Numbers: Two large, distinct prime numbers (p and q) are chosen secretly. 🔹 Computing the Modulus: Multiplying them gives n = p × q, forming part of both keys. 🔹 Calculating Euler’s Totient Function:φ(n) = (p - 1) × (q - 1), a crucial component for defining key exponents. 🔹 Choosing the Public Exponent (e): A number e is selected where 1 < e < φ(n) and gcd(e, φ(n)) = 1 (common choice: 65537 for efficiency). 🔹 Deriving the Private Exponent (d): The modular inverse of e mod φ(n), ensuring (d × e) mod φ(n) = 1.

Choose primes: p = 3, q = 11

Compute n: n = p * q = 3 * 11 = 33

Compute φ(n): φ(n) = (p - 1) * (q - 1) = (3 - 1) * (11 - 1) = 2 * 10 = 20

Choose 'e': We need 1 < e < 20 and gcd(e, 20) = 1. Let's choose e = 3 (gcd(3, 20) = 1).

Compute 'd': We need to find 'd' such that (3 * d) mod 20 = 1. By trying values or using the Extended Euclidean Algorithm:

3 * 1 = 3 mod 20
3 * 2 = 6 mod 20
3 * 3 = 9 mod 20
3 * 4 = 12 mod 20
3 * 5 = 15 mod 20
3 * 6 = 18 mod 20
3 * 7 = 21 mod 20 = 1 So, d = 7.

Public Key: (n = 33, e = 3)

Private Key: (n = 33, d = 7)

  1. Encryption: Securing the Message
    A sender encrypts a message m (converted into a numeric format) using the recipient’s public key (n, e):
    c = m^e mod n

  2. Decryption: Retrieving the Original Message
    The recipient, using their private key (n, d), decrypts the message:
    m = c^d mod n

Let's Try the encryption and decryption using the example message as "Secret":

We need to convert the letters of "secret" into numbers. A simple way is to assign each letter a number based on its position in the alphabet (A=0, B=1, ..., Z=25).

s = 18
e = 4
c = 2
r = 17
e = 4
t = 19
Since our modulus 'n' is 33, and all our letter representations are less than 33, we can encrypt each letter individually.

Encryption:

We encrypt each letter's numerical representation 'm' using the formula: c = m^e mod n

s (m=18): c = 18^3 mod 33 = 5832 mod 33
5832 / 33 = 176 with a remainder of 24. So, c = 24.
e (m=4): c = 4^3 mod 33 = 64 mod 33
64 / 33 = 1 with a remainder of 31. So, c = 31.
c (m=2): c = 2^3 mod 33 = 8 mod 33
So, c = 8.
r (m=17): c = 17^3 mod 33 = 4913 mod 33
4913 / 33 = 148 with a remainder of 29. So, c = 29.
e (m=4): c = 4^3 mod 33 = 64 mod 33 = 31 (same as the first 'e').
t (m=19): c = 19^3 mod 33 = 6859 mod 33
6859 / 33 = 207 with a remainder of 28. So, c = 28.
The encrypted message (ciphertext) as a sequence of numbers is: 24, 31, 8, 29, 31, 28

Decryption:

To decrypt, we use the private key (n=33, d=7) and the formula: m = c^d mod n

24: m = 24^7 mod 33

24^2 mod 33 = 576 mod 33 = (17 * 33 + 15) mod 33 = 15
24^4 mod 33 = 15^2 mod 33 = 225 mod 33 = (6 * 33 + 27) mod 33 = 27
24^6 mod 33 = 24^4 * 24^2 mod 33 = 27 * 15 mod 33 = 405 mod 33 = (12 * 33 + 9) mod 33 = 9
24^7 mod 33 = 24^6 * 24^1 mod 33 = 9 * 24 mod 33 = 216 mod 33 = (6 * 33 + 18) mod 33 = 18 (which is 's')

31: m = 31^7 mod 33

Notice that 31 ≡ -2 (mod 33). So, 31^7 ≡ (-2)^7 mod 33 = -128 mod 33
-128 + (4 * 33) = -128 + 132 = 4. So, m = 4 (which is 'e')

8: m = 8^7 mod 33

8^2 mod 33 = 64 mod 33 = 31 ≡ -2 (mod 33)
8^4 mod 33 ≡ (-2)^2 mod 33 = 4
8^6 mod 33 ≡ (-2)^3 mod 33 = -8 ≡ 25 (mod 33)
8^7 mod 33 ≡ (-2)^3 * 8 mod 33 = -8 * 8 mod 33 = -64 mod 33 ≡ -64 + (2 * 33) mod 33 = -64 + 66 mod 33 = 2 (which is 'c')

29: m = 29^7 mod 33

Notice that 29 ≡ -4 (mod 33). So, 29^7 ≡ (-4)^7 mod 33 = -16384 mod 33
-16384 / 33 ≈ -496.48
-16384 + (497 * 33) = -16384 + 16401 = 17. So, m = 17 (which is 'r')

31: We already calculated this, m = 4 (which is 'e')

28: m = 28^7 mod 33

Notice that 28 ≡ -5 (mod 33). So, 28^7 ≡ (-5)^7 mod 33 = -78125 mod 33
-78125 / 33 ≈ -2367.42
-78125 + (2368 * 33) = -78125 + 78144 = 19. So, m = 19 (which is 't')

The decrypted message numbers are: 18, 4, 2, 17, 4, 19, which correspond back to the letters s, e, c, r, e, t.

To ensure that a message encrypted with RSA is also tamper-proof, you need to employ additional cryptographic techniques alongside the encryption process. The most common way to do this is by using digital signatures.

Beyond Encryption: Digital Signatures for Authentication
While RSA encrypts data for confidentiality, it also plays a key role in digital signatures, ensuring:
✔ Authenticity – The sender’s identity is verified.
✔ Integrity – The message hasn’t been altered in transit.
✔ Non-Repudiation – The sender cannot deny sending the message.

Real-World Applications of RSA Encryption
🔹Secure Web Browsing (HTTPS): When you access online banking, your browser encrypts a session key using the bank’s RSA public key, establishing a secure connection.
🔹Secure Email (S/MIME, PGP/GPG): Lawyers and professionals use RSA to encrypt and sign sensitive emails, ensuring privacy and authenticity.
🔹Virtual Private Networks (VPNs): RSA plays a role in VPN authentication, securing remote connections between employees and corporate networks.
🔹Secure Shell (SSH): System administrators use RSA-based key authentication for secure, password less remote access.
🔹Software Updates & Code Signing: RSA ensures software updates come from verified sources, protecting against tampered or malicious installations.

The Future: Preparing for Post-Quantum Cryptography
With the rise of quantum computing, RSA’s security—based on integer factorization, faces potential threats. The cryptographic community is actively developing post-quantum cryptography (PQC) to ensure secure digital interactions in the future.

Final Thoughts
RSA encryption is a cornerstone of modern cybersecurity. Its strong mathematical foundation and widespread adoption make it indispensable for secure communication. Understanding RSA and its complementary techniques, like digital signatures, is crucial for professionals navigating the digital security landscape.

As technology evolves, staying ahead in encryption trends and transitioning to post-quantum cryptography will be key to safeguarding digital interactions.

🔐 How do you see encryption evolving in the next decade? Let’s discuss! 👇