Categories
Uncategorized

RSA Algorithm

Given will be the p and q which is the prime numbers. lets take:

p=3 and q=11——– prime numbers.

First step is Generation of keys

since RSA uses two keys that is public and private so,

using this we will get the first public key i.e.

N=p*q= 3*11=33 where N is the first public key.

we will also find z by the formula :

Z= (p-1)*(q-1)

z=(3-1)*(11-1)

z=2*10

z=20

choose ‘K’ a prime number such that z is not divided by k.

so, k will be 7

// we choose this by seeing prime number as 1,3,5,7,11,13,17,………

//we don’t choose 1 mostly. 3 is already used. we take 5 but it is divisible by z so, we cannot take 5. That’s why we choose k=7.

Now we will find the Private key. To find the private key we use this function:

k * j= 1 |mod (z)| where k is the public key, j is the private key.

7 * j= 1 mod|20| // this says that whatever the quotient be remainder should be 1.

(7 * j)/20= 1

so, substituting the value of j as 1,2,3 we get

7*1/20=7/20 != reminder  1.

7*2/20=14/20 != reminder 1.

7*3/20 =21/20 = reminder 1.

so, j will be 3 i.e

j=3—– private key.

Second method is Encryption

For encryption the equation will be P^k= e (mod n) where P is the plain text, k is the public key, n is the public key, e is the cipher text.

given plain text is P=14.

substituting the value in the equation we get:

14^7=e (mod 33)

or, 105413504/33=e

or, 3194348.60=e //it is not the e coz we need to get the remainder of this. so ,we take only the decimal number that is 3194348 and multiply by 33

3194348*33= 105413484

Now to get e we have to subtract 105413504 with 105413484 and we get e =20 ( 105413504-10541384)

e is the cipher text  that is e= 20.