RSA Algorithm mathematical explanation

Kapil Verma
2 min readJun 5, 2019

--

• RSA algorithm is used majorly for key exchange for symmetric encryption
• The RSA cryptosystem is the most widely-used public key cryptography algorithm in the world.
• It can be used to encrypt a message without the need to exchange a secret key separately.
• The RSA algorithm can be used for both public key encryption and digital signatures.
• Its security is based on the difficulty of factoring large integers.

1. See, public key has 2 parts ‘e’ and ‘n’.
2. No we need ‘n’.
1. n=P * Q.
2. Here, P and Q and 2 Prime numbers.
3. Lets assume p=53, and Q =59
4. n=P * Q
5. n=53 * 59=3127
3. Now we need ‘e’.
1. ‘e’ is such that it should be and integer and,
2. 1 < e < Ф(n)
3. Here Ф(n)=(P-1)*(Q-1)
4. So, Ф(n)=(53–1)*(59–1)
5. Ф(n)= 3016
6. Let’s take any value of e in the range of 1 and 3016
7. let’s assume e=3
4. Now our public Key is (n,e)=(n=3127, e=3)

5. Now, we need to work for private key ‘d’.
1. d=[(K* Ф(n))+1]/e
2. for any integer k=2,
→ d =[(2*3016)+1]/3
→ d=6033/3=2011
3. So your private key is d==2011.

6. Now Let’ Encrypt any Message.
→Suppose A=1 and Z=26.
→So HI = 89.

7.Now to encrypt our message we need public key(n=3127, e=3)
8. Encrypted message c = 89^e mod n =1394.

7. Now, Decrypting:
→Our encrypted message is 1394.
→Decrypted Data = c^d mod n=89.

--

--