Vernam Cipher is a method of encrypting alphabetic text. It is simply a type of substitution cipher. In this mechanism we assign a number to each character of the Plain-Text, like (a = 0, b = 1, c = 2, … z = 25).
Method to take key:
In Vernam cipher algorithm, we take a key to encrypt the plain text which length should be equal to the length of the plain text.
- Assign a number to each character of the plain-text and the key according to alphabetical order.
- Add both the number (Corresponding plain-text character number and Key character number).
- Subtract the number from 26 if the added number is greater than 26, if it isn’t then leave it.
Plain-Text: RAMSWARUPK Key: RANCHOBABA
Now according to our encryption algorithm we assign a number to each character of our plain-text and key.
PT: R A M S W A R U P K NO: 17 0 12 18 22 0 17 20 15 10 KEY: R A N C H O B A B A NO: 17 0 13 2 7 14 1 0 1 0
Now add the number of Plain-Text and Key and after doing the addition and subtraction operation (if required), we will get the corresponding Cipher-Text character number.
CT-NO: 34 0 25 20 29 14 18 20 16 10
In this case, there are two numbers which are greater than the 26 so we have to subtract 26 from them and after applying the subtraction operation the new Cipher text character numbers are as follow:
CT-NO: 8 0 25 20 3 14 18 20 16 10
New Cipher-Text is after getting the corresponding character from the number.
CIPHER-TEXT: I A Z U D O S U Q K
For the Decryption apply the just reverse process of encryption.
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- Caesar Cipher in Cryptography
- Bifid Cipher in Cryptography
- Custom Building Cryptography Algorithms (Hybrid Cryptography)
- Difference between Monoalphabetic Cipher and Polyalphabetic Cipher
- Difference between Block Cipher and Stream Cipher
- Difference between Block Cipher and Transposition Cipher
- Classical Cryptography and Quantum Cryptography
- Difference between Substitution Cipher Technique and Transposition Cipher Technique
- DNA Cryptography
- RSA Algorithm in Cryptography
- Quantum Cryptography
- Development of Cryptography
- Cryptography and its Types
- The CIA triad in Cryptography
- Cryptography Introduction
- Birthday attack in Cryptography
- Difference between Steganography and Cryptography
- Difference between Cryptography and Cryptology
- Easy Key Management in Cryptography
- Image Steganography in Cryptography
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : abhirgonepavaram13