×

Cyber Security

Intrusion Detection System (IDS)

Caesar Cipher | Cyber Security

By Sahil Singh, on September 28, 2019

What is Caesar Cipher?

Caesar Cipher is one of the simplest encryption techniques. In this, every letter is represented by a fixed number. For example, A is represented by 0, B is represented by 1, C is represented by 2, and so on (till Z). In Caesar Cipher we take a small integer value which we use for shifting. For example, if we took 3 as out shifting key and we are shifting towards the right side, then A will become D (As A+3 = 0+3 = 3 which is equal to D). Similarly, B would become E and so on. If we are doing left shift then D will become A, E would become B and so on. This method was invented by "Julius Caesar" who used this method for the privacy of his messages, hence was named after his name as Caesar Cipher.

In the Caesar Cipher, we perform two types of shift operations: either the left shift or the right. In the left shift, we minus the key value from the numeric value assigned to each digit of the plain text, whereas in the right shift, we add the key value. Hence, the encryption is done as follows:

Plain text: M
Given key: k
Cipher text:
Left shift:  (m-k) % 26	{Here, m is each letter in the PT}
Right shift: (m+k) % 26

Caesar Cipher Example

Given Plain Text : A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

1) Let us suppose that the key = 2

Left Shift: In the left shift, perform the following operation on each letter of the plain text: (m-k)%26, i.e. (m-2)%26.

    Plain Text :    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
    Cipher Text :   Y Z A B C D E F G H I J K L M N O P Q R S T U V W X

Right Shift: In the right shift, perform the following operation on each letter of the plain text: (m+k)%26, i.e. (m+2)%26

    Plain Text :    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
    Cipher Text :   C D E F G H I J K L M N O P Q R S T U V W X Y Z A B    

2) Let us suppose that the key = 3

Left Shift: Perform the following operation on each letter of the plain text: (m-k)%26, i.e. (m-3)%26

    Plain Text :    A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
    Cipher Text :   X Y Z A B C D E F G H I J K L M N O P Q R S T U V W 

Right Shift: Perform the following operation on each letter of the plain text: (m+k)%26, i.e. (m+3)%26

    Plain Text :    A B C D E F G H I  J  K L M N O P Q R S T U V W X Y Z
    Cipher Text :   D E F G H  I  J K L M N O P Q R S T U V W X Y Z A B C

Now, let us encrypt a sentence using the Caesar Cipher...

Given plain text sentence to be encrypted: "IF YOU HAVE A DREAM TO CHASE, NOTHING CAN STOP YOU".

Now let us take the key value 3 with the right shift operation:

Therefore, we perform the following operation on each letter of the plain text: (m+k)%26, i.e. (m+3)%26

Cipher Text Sentence: "LI BRX KDYH D GUHDP WR FKDVH, QRWKLQJ FDQ VWRS BRX".

Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.