Caesar Cipher
Introduction
The Caesar cipher is named after the Roman military and political leader Gaius Julius Caesar (100 BC - 44 BC). Julius Caesar used this simple encryption technique to send secret messages to his allies.It works by shifting the letters in the plaintext message by a certain number of positions, known as the “shift” or “key”.
Encryption: C = (P + K)mod26
Decryption: P = (C - K)mod26
where, P → Plaintext
C → Ciphertext
K → Shift/Key
Index Table
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 |
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |
Example: Using Caesar cipher encrypt the message "HELLO" with a shift of 3.
Step 1: Write down the plaintext message: HELLO
Step 2: Choose a shift value. In this case, we will use a shift of 3.
Step 3: Replace each letter in the plaintext message with the letter that is three
positions to
the right in the alphabet.
H becomes K (shift 3 from
H)
E becomes H (shift 3 from
E)
L becomes O (shift 3 from
L)
L becomes O (shift 3 from
L)
O becomes R (shift 3 from O)
Step 4: Thus, the encrypted message will "KHOOR".
Note: To decrypt the message, you simply need to shift each letter back by the same
number of positions.
In this case, you would shift each letter in "KHOOR" back by 3 positions to get the original
message, “HELLO”.
Security
The number of possible keys is identical to the size of the given alphabet. Using the capital letters A-Z as alphabet allows 26 different keys, with the 26th key rendered meaningless because it would map each letter to itself. With only 25 meaningful keys, it would be quite easy to test for all possible keys until the correct one is found (brute-force analysis). The Caesar cipher can also easily be cracked with a frequency analysis.
Advantages
- It is very easy to implement.
- This method is the simplest method of cryptography.
- Only one short key is used in its entire process.
- If a system does not use complex coding techniques, it is the best method for it.
- It requires only a few computing resources.
Disadvantages
- It is not secure against modern decryption methods.
- Vulnerable to known-plaintext attacks, where an attacker has access to both the encrypted and unencrypted versions of the same messages.
- The small number of possible keys means that an attacker can easily try all possible keys until the correct one is found, making it vulnerable to a brute force attack.
- It is not suitable for long text encryption as it would be easy to crack.