Examples of Encrypting with RSA

Examples of Encrypting with RSA

Suppose that P represents plain text. If we apply RSA encrpytion on P with the public information [n, e], we will obtain a C known as ciphertext. We are now going to give some examples of using RSA encryption to convert P to C, namely using the following congruence:

(1)
\begin{align} C \equiv P^e \pmod {n} \end{align}

Note that if we have the decryption key, we can also decrypt messages. Click here to see some example of RSA decryption.

Example 1

Given the public information [n, e] = [143, 11], encrypt the message P = 7.

We know that $C \equiv P^e \pmod {n}$, more specifically $C \equiv 7^{11} \mod {143}$. Now we can solve for the ciphertext C:

(2)
\begin{align} 7 \equiv 7 \pmod {143} \\ 7^2 \equiv 49 \pmod {143} \\ 7^4 \equiv (49)^2 = 2401 \equiv 113 \pmod {143} \\ 7^8 \equiv (113)^2 = 12769 \equiv 42 \pmod {143} \\ 7^{11} \equiv (42)(49)(7) = 14406 \equiv 106 \pmod {143} \end{align}

Hence if our plaintext P = 7, then when encrypted, our ciphertext C = 106.

Example 2

Given the public information [n, e] = [299, 17], encrypt the message P = 55.

Once again we know that $C \equiv P^e \pmod {n}$, more specifically $C \equiv 55^{17} \pmod {299}$. We must now evaluate this congruence as follows:

(3)
\begin{align} 55 \equiv 55 \pmod {299} \\ 55^2 = 3025 \equiv 35 \pmod {299} \\ 55^4 \equiv (35)^2 = 1225 \equiv 29 \pmod {299} \\ 55^8 \equiv (29)^2 = 841 \equiv 243 \pmod {299} \\ 55^{16} \equiv (243)^2 = 59049 \equiv 146 \pmod {299} \\ 55^{17} \equiv (146)(55) = 8030 \equiv 256 \pmod {299} \end{align}

Hence our ciphertext C = 256.

Example 3

Given the public information [n, e] = [221, 19], encrypt the message P = 28.

We know that $C \equiv 28^19 \pmod {221}$. Now let's solve this congruence:

(4)
\begin{align} 28 \equiv 28 \pmod {221} \\ 28^2 = 784 \equiv 121 \pmod {221} \\ 28^4 \equiv (121)^2 = 14641 \equiv 55 \pmod {221} \\ 28^8 \equiv (55)^2 = 3025 \equiv 152 \pmod {221} \\ 28^{16} \equiv (152)^2 = 23104 \equiv 120 \pmod {221} \\ 28^{19} \equiv (120)(121)(28) = 406560 \equiv 141 \pmod {221} \end{align}

Hence our ciphertext C = 141.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License