RSA Encryption Explained With Example

rsa encryption explained with example

The need to protect sensitive information during transmission has led to the development of various encryption algorithms. One of the most widely used and robust encryption techniques is RSA (Rivest-Shamir-Adleman). In this blog post, we will discuss into the intricacies of RSA encryption, exploring its underlying principles and providing practical example to enhance your understanding.


RSA Encryption Basics

RSA encryption is a public-key cryptography algorithm that utilizes two keys – a public key and a private key. The public key is shared openly, allowing anyone to encrypt messages, while the private key is kept secret and is used for decryption. The security of RSA encryption is based on the difficulty of factoring the product of two large prime numbers.


Key Generation

The first step in implementing RSA encryption involves generating a pair of public and private keys. Let’s walk through a simplified example:

1. Choose two large prime numbers, p and q.

  • p = 61
  • q = 53

2. Calculate the product of p and q to obtain n.

  • n = p * q = 61 * 53 = 3233

3. Compute the totient (φ) of n.

  • φ(n) = (p-1) * (q-1) = 60 * 52 = 3120

4. Select a public exponent (e) that is coprime with φ(n) and less than φ(n).

  • e = 17

5. Determine the private exponent (d) such that (d * e) % φ(n) = 1.

  • d = 2753

Now, we have our public key (e, n) = (17, 3233) and private key (d, n) = (2753, 3233).


Encryption Process

With the public key in place, anyone can encrypt a message for the intended recipient. Let’s say Alice wants to send a message to Bob:

1. Bob shares his public key (e, n) = (17, 3233) with Alice.

2. Alice converts her plaintext message into numerical form, ensuring it is less than n.

  • Message: “HELLO”
  • Numerical representation: H=8, E=5, L=12, L=12, O=15
  • Combined: 8 5 12 12 15

3. Encrypt the numerical message using Bob’s public key.

  • Encrypted message (ciphertext) = (8^17 % 3233, 5^17 % 3233, 12^17 % 3233, 12^17 % 3233, 15^17 % 3233)

Decryption Process

Bob, as the recipient, can decrypt the message using his private key:

1. Bob uses his private key (d, n) = (2753, 3233) for decryption.

2. Decrypt the ciphertext using the private key.

  • Decrypted message = (ciphertext^2753 % 3233)

3. Convert the numerical result back into the original plaintext message.

  • Numerical result: 8 5 12 12 15
  • Combined: “HELLO”


RSA encryption plays a crucial role in securing digital communication by leveraging the mathematical properties of prime numbers. The algorithm’s strength lies in the complexity of factoring large numbers, making it a robust choice for protecting sensitive information. As technology continues to advance, understanding encryption algorithms like RSA becomes increasingly important in ensuring the confidentiality and integrity of data in the digital world.

Read On CCNA 200-301

Image by wirestock on Freepik

Leave a Comment

Your email address will not be published. Required fields are marked *