**Substitution technique** is a classical encryption technique where the characters present in the **original message** are **replaced** by the **other characters or numbers or by symbols.** If the plain text (original message) is considered as the string of bits, then the substitution technique would replace bit pattern of plain text with the bit pattern of cipher text.

We will discuss some of the substitution techniques which will help us to understand the procedure of converting plain text o cipher text. In this section, we will study the following substitution techniques:

## Substitution Technique:

- Caesar Cipher
- Monoalphabetic Cipher
- Playfair Cipher
- Hill Cipher
- Polyalphabetic Cipher
- One-Time Pad

### Caesar Cipher

This the simplest substitution cipher by Julius Caesar. In this substitution technique, to encrypt the plain text, each alphabet of the plain text is replaced by the alphabet three places further it. And to decrypt the cipher text each alphabet of cipher text is replaced by the alphabet three places before it.

Let us take a simple example:

**Plain Text:** meet me tomorrow

**Cipher Text:** phhw ph wrpruurz

Look at the example above, we have replaced, ‘m’ with ‘p’ which occur three places after, ‘m’. Similarly, ‘e’ is replaced with ‘h’ which occurs in three places after ‘e’.

**Note:** If we have to replace the letter ‘z’ then the next three alphabets counted after ‘z’ will be ‘a’ ‘b’ ‘c’. So, while counting further three alphabets if ‘z’ occurs it circularly follows ‘a’.

There are also some drawbacks of this simple substitution technique. If the hacker knows that the Caesar cipher is used then to perform brute force cryptanalysis, he has only to try 25 possible keys to decrypt the plain text.

The hacker is also aware of the encryption and decryption algorithm.

### Monoalphabetic Cipher

Monoalphabetic cipher is a substitution cipher, where the cipher alphabet for each plain text alphabet is fixed, for the entire encryption.

In simple words, if the alphabet ‘p’ in the plain text is replaced by the cipher alphabet ‘d’. Then in the entire plain text wherever alphabet ‘p’ is used, it will be replaced by the alphabet ‘d’ to form the ciphertext.

### Playfair Cipher

Playfair cipher is a substitution cipher which involves a 5X5 matrix. Let us discuss the technique of this Playfair cipher with the help of an example:

**Plain Text:** meet me tomorrow

**Key:** KEYWORD

Now, we have to convert this plain text to ciphertext using the given key. We will discuss the further process in steps.

**Step 1:** Create a 5X5 matrix and place the key in that matrix row-wise from left to right. Then put the remaining alphabet in the blank space.

**Note:** If a key has duplicate alphabets, then fill those alphabets only once in the matrix, and I & J should be kept together in the matrix even though they occur in the given key.

**Step 2:** Now, you have to break the plain text into a pair of alphabets.

**Plain Text:** meet me tomorrow

**Pair:** __me__ __et__ __me__ __to__ __mo__ __rx__ __ro__ __wz__

**Note**

- Pair of alphabets must not contain the same letter. In case, pair has the same letter then break it and add ‘x’ to the previous letter. Like in our example letter ‘rr’ occurs in pair so, we have broken that pair and added ‘x’ to the first ‘r’.
- In case while making pair, the last pair has only one alphabet left then we add ‘z’ to that alphabet to form a pair as in our above example, we have added ‘z’ to ‘w’ because ‘w’ was left alone at last.
- If a pair has ‘xx’ then we break it and add ‘z’ to the first ‘x’, i.e. ‘xz’ and ‘x_’.

**Step 3:** In this step, we will convert plain text into ciphertext. For that, take the first pair of plain text and check for cipher alphabets for the corresponding in the matrix. To find cipher alphabets follow the rules below.

**Note**

- If both the alphabets of the pair occur in the
**same row**replace them with the alphabet to their**immediate right**. If an alphabet of the pair occurs at extreme right then replace it with the first element of that row, i.e. the last element of the row in the matrix circularly follows the first element of the same row. - If the alphabets in the pair occur in the
**same column**, then replace them with the alphabet**immediate below**them. Here also, the last element of the column circularly follows the first element of the same column. - If the alphabets in the pair are
**neither in the same column and nor in the same row,**then the alphabet is replaced by the element in its own row and the corresponding column of the other alphabet of the pair.

**Pair:** __me__ __et__ __me__ __to__ __mo__ __rx__ __ro__ __wz__

**Cipher Text:** kn ku kn kz ks ta kc yo

So, this is how we can convert a plain text to ciphertext using Playfair cipher. When compared with monoalphabetic cipher Playfair cipher is much more advanced. But still, it is easy to break.

### Hill Cipher

Hill cipher is a polyalphabetic cipher introduced by Lester Hill in 1929. Let us discuss the technique of hill cipher.

**Plain text:** Binary

**Key:** HILL

**Choose the key** in such a way that it always forms a **square matrix**. With HILL as the key, we can form a 2×2 matrix.

Now, of plain text, you have to form a column vector of length similar to the key matrix. In our case, the key matrix is 2×2 then the column vectors of plain text would be 2×1.

The general equation to find cipher text using hill cipher is as follow:

*C = KP mod 26*

For our example, our key matrix would be:

And our plain text matrices of 2×1 will be as follow:

Now, we have to convert the key matrix and plain text matrices into numeric matrices. For that number the alphabets such as A=0, B=1, C=2, …………, Z=25. So, considering the alphabet numbering:

Key matrix will be:

Plain text matrices would be:

In the first calculation, we would get two cipher alphabets for plain text alphabet ‘B’ & ‘I’.

So, the cipher alphabet for plain text alphabet ‘B’ & ‘I’ is ‘T’ & ‘V’. Similarly, we have to calculate ciphertext for remaining plain text. And then accumulate them to form the ciphertext.

The calculated **ciphertext** for ‘**Binary**’ using hill cipher is ‘**TVNNZJ**’.

### Polyalphabetic Cipher

Polyalphabetic cipher is far more secure than a monoalphabetic cipher. As monoalphabetic cipher maps a plain text symbol or alphabet to a ciphertext symbol and uses the same ciphertext symbol wherever that plain text occurs in the message.

But polyalphabetic cipher, each time replaces the plain text with the different ciphertext.

### One-Time Pad

The one-time pad cipher suggests that the **key length** should be **as long as the plain text** to prevent the repetition of key. Along with that, the **key** should be **used** only **once** to encrypt and decrypt the single message after that the key should be discarded.

Onetime pad suggests a new key for each new message and of the same length as a new message. Now, let us see the one-time pad technique to convert plain text into ciphertext. Assume our plain text and key be:

**Plain text:** Binary

**Key:** Cipher

Now again convert the plain text and key into the numeric form. For that number the alphabets such as A=0, B=1, C=2, …………, Z=25. So, our plain text and key in numeric form would be:

**Plain text:** 1 8 13 0 17 24

**Key:** 2 8 15 7 4 17

Now, you have to add the number of the plain text alphabet, to the number of its corresponding key alphabet. That means, for this example, we will add:

**B+C = 1+2 = 3**

**I+I = 8+8 = 16**

**N+P = 13+15 = 28**

**A+H = 0+7 = 7**

**R+E = 17+4 = 21**

**Y+R = 24+17 = 41**

The resultant ciphertext numbers we get are (3, 16, 28, 7, 21, 41)

If the addition of any plain text number and the key number is >26, then subtract only that particular number from 26. We have the addition of two pair of plain text number and a key number, greater than 26, i.e. N+P=28 & Y+R=41.

Subtract them by 26.

N+P = 28 – 26 = 2

Y+R = 41 – 26 = 15

So, the final **ciphertext numbers are (3, 16, 2, 7, 21, 15)**. Now convert this number to alphabets assuming A to be numbered 0 and B to be 1…..Z to 25.

**Ciphertext:** dqchvp.

In this way, we can convert plain text to cipher text using a one-time pad.

So, this is all about the substitution cipher techniques. It has a monoalphabetic cipher and polyalphabetic cipher technique. Substitution technique is also called classical substitution technique.

### Related Terms:

- Block Cipher
- Transposition Technique in Cryptography
- Feistel Block Cipher
- Advanced Encryption Standard (AES)
- Data Encryption Standard (DES)