##### Substitutional Cipher | Caesar cipher | Monoalphabetic cipher | Playfair cipher | Viginere cipher | Hill cipher | Vernam cipher

Substitutional cipher:

It involves the replacement of characters given in the plain text and is converted to the cipher text with the replaced characters.

Examples:

• Caesar cipher
• Monoalphabetic cipher
• Playfair cipher
• Viginere cipher
• Hill cipher
• Vernam cipher

Ceasar cipher:

Ceaser cipher replaces each plain text character by character by K positions to the right.

Encryption:

(Index value (plain letter) + key)mod(26).

Decryption:

(Index value (cipher letter) - key)mod(26).

Key is defined with K in the ceasar cipher.

Example:

I got selected in this internship.

We have to encrypt that with key value as 3.

Initially take the alphabets and their indices. Step 1:

Segregate all the letters given in the plain text.

I g o t s e l e c t e d I n t h I s I n t e r n s h I p.

Apply the encryption formulae.( consider the index of every letter)   So the encrypted cipher text is

L  JRW  VHOHFWGH  LQ  WKLV  LQWUPQVKLS.

For the decryption we have to do similar computation but we have to subtract key from the obtained cipher text.

Mono-alphabetic cipher:

In this type of encryption mechanism we have predefined characters for every individual alphabet. We have to simply replace the plain text with the given suitable letter to get the cipher text.

For example consider the following: In the above table we are given with the replaced letter for every individual alphabet.

Example:

I got selected for this internship.

Check for the respective symbols for the given plain text from the above mentioned table.   So the encrypted cipher text will be as follows:

D  BSN  YMGMKNML  ASX  NCDY   DRNEXRYCDT

For the decryption process sender has to share the replaced information table with the recipient so that he can view the individual character to get the plain text back.

Play fair cipher:

In this type of encryption mechanism we use a 5X5 matrix to encrypt the message. We have to select a word which has the non-repeating characters in it. We have to divide the plain text into the groups.

First we have to fill the key in the matrix row wise and then we have to fill the remaining letters and the major constrain is selected key consists of non-repeating characters.

We have to put any two in the same box if and only if there is no space for putting entire 26 alphabets in the 25 cells.

Rules for the encryption in play fair:

1. If a character is left over while grouping add letter X with the left over alphabet.
2. If the fall in the same row then replace each with the letters in the right (circularly).
3. If the letters fall in the same column replace each with the letter below (circularly).
4. Else replace each letter with the letter in the same row but in the same column of the otter letter of the pair.

For example:

Consider key as MONARCHY.

Fill the key first in the matrix row wise. Fill the remaining letters in the remaining cells order wise. Put i/j in the same box. We can proceed with any two. Plain text as MOVE FORWARD.

Split the plain text as grouping the elements into two.

MO VE FO RW AR DX

As per the rule pad the leftover with X.

Check for MO the plair is in same row. So replace M with O as it is right to M. and replace O with N as it is right to O.

Check for VE the pair is the box not in same row not in same column. So we have to encrypt the pair using rule 4. Replace V with U as U is present in the column of E.

Replace E with F as F is present in the column of V.
Check for FO the pair is in the same column. As the pair is in the same column, we have to replace the letter with the below ones as per the rule 3.

Replace F with P.

Replace O with H.

Check for RW the pair is in the box.

We have to follow rule 4 for encrypting the pair because those are not in same row or column. Replace R with N as N is present in the column of W.

Replace W with Z as Z is present in the column of R.

Check for AR the pair is in same row. So replace A with R as it is right to A. and replace R with M as it is right to R.

Check for DX the pair is in the box

We have to follow rule 4 for encrypting the pair because those are not in same row or column. Replace D with B as B is present in the column of X.

Replace X with Z as Z is present in the column of D.

So the final encrypted cipher text will be.

ONUF PHNZRMBZ

For the decryption process we have to follow the same procedure and rules will be changed.

Rules for the decryption in play fair:

1. If a character is left over while grouping add letter X with the left over alphabet.
2. If the fall in the same row then replace each with the letters in the left (circularly).
3. If the letters fall in the same column replace each with the letter above (circularly).
4. Else replace each letter with the letter in the same row but in the same column of the otter letter of the pair.

Hill cipher:

It is an encryption technique which uses nXn matrix as key for the encryption/decryption.

Encryption:

C= KPmod26

Where

C= cipher text.

K= secret key.

P= plain text.

Example:

Plain text: HATS So the final encrypted text is VOHY.

To decrypt the cipher text we have to apply the below formulae.

Decryption:

P= K-1Cmod26

Vigener cipher:

In this type of encryption mechanism we encrypt the plain text with the repeated usage of key. Example:

Plain text: opensense labs.

Key: osl

Write plain text as it is

O P E N S E N S E L A B S

O S L O S L O S L O S L O (repeat the key until all the letters in the plain text has a letter underneath it).

mark all the indices of the characters in both the plain text and the secret key. So the final cipher text will be

CHPBKPBKPZSMG

Vernam cipher:

It is an encryption mechanism which will convert the plain text into the byte string based on the ASCII values of the character. It is also called as one time pad.

Bit wise xor operation is performed to encrypt the message.

ASCII values:  