You are on page 1of 2

Vernam(Enc) :

---
Step1: Take a Plain text and Key from user
Step2: Assign a number to each character of the plain-text and the key according to
alphabetical order(A-0,B-1,..,Z-25).
Step3: Add both the number (Corresponding plain-text character number and Key
character number).
Step4: Subtract the number from 26 if the added number is greater than 26, if it
isn’t then leave it.
Step5: Assign the character to each number according to alphabetical order(0-A,1-
B,..,25-Z) and print the Cipher text.

Vernam(Dec):
---
Step1: Take the Cipher text and Key from user
Step2: Assign a number to each character of the cipher-text and the key according
to alphabetical order(A-0,B-1,..,Z-25).
Step3: Substract both the number (Corresponding plain-text character number and Key
character number).
Step4: Add the number from 26 if the added number is less than 26, if it isn’t then
leave it.
Step5: Assign the character to each number according to alphabetical order(0-A,1-
B,..,25-Z) and print the Plain Text.

---------------
Diffie Hellman Algorithm
---
Step1: Enter a prime number, say q
Step2: Find the primitive root of that prime number and it should be less than
prime number,say a
Step3: Take the private key from user1,say x1
Step4: Find the public key of user1 using (a^x1)mod(q)
Step5: Take the private key from user2,say x2
Step6: Find the public key of user2 using (a^x2)mod(q)
Step7: Now, Find the secret key for both user1 and user2. For user1, (public key of
user2)^(private key of user1)mod(prime number taken first). For user2, (public key
of user1)^(private key of user2)mod(prime number taken first)
Step8: If both the key are same then Key exchange successful else not successful.

-----
RSA Algorithm
----
Step1: Enter two different large prime number,say p and q
Step2: Find the multiplication of those two prime numbers,say n
Step3: Find the phi(n) using (p-1)*(q-1)
Step4: Enter a number that is coprime to phi(n),say e, i.e., the gcd(e,phi(n)) is 1
Step5: Calculate d=(e^-1)mod(phi(n))
Step6: Public key is {e,n} and Private Key is {d,n}

To Encrypt using RSA-


step1. Take a plain text from user
step2. Calculate the ASCII value of each character of the text and store it in an
array,say a[i]
step3. Find the cipher using, (a[i]^e)mod(n), where (e,n) is the public key

To Decrypt using RSA-


step1. Take a cipher from user
step2. Take the encrypted cipher value of each character and store it in an
array,say c[i]
step3. Find the plain text using, (c[i]^d)mod(n) where (d,n) is the private key

---------------------------------------------------
EXTRAS
---------------------------------------------------
Caeser Cipher
--------
Step1: Take the plain text from the user
Step2: Take a integer value for key, by default it is 3
Step3: Assign a number to each character of the plain-text and the key according to
alphabetical order(A-0,B-1,..,Z-25),say X
Step4: To Encrypt, Add the key and the alphabetical order number and find the
modulas, (X+Key)mod(26)
Step5: To Decrypt, Substract the key and the alphabetical order number and find the
modulas, (X-Key)mod(26)

You might also like