The Caesar Cipher is a type of classical encryption technique which uses either substitution or transposition only. Substitution ciphers can be further divided into monoalphabetic and polyalphabetic ciphers.
The Caesar Cipher is the earliest known substitution cipher, used by Julius Caesar. It replaces each letter in the plaintext with the letter that is a fixed number of positions down the alphabet. For example, with a key (K) of 10, 'a' becomes 'k'.
Given the secret message P: "hello", and the key K: "10":
Plaintext: hello
Key: 10
Encrypted Message (Ciphertext): rovvy
The formula used is:
C = E(P) = (P + K) mod 26
or C = E(P) = (P - K) mod 26
To understand modular operations, consider this example: If 6 hours pass, what time is it? A common mistake would be to answer 13, but on a 12-hour clock, it would be 1: 7 + 6 mod 12 = 1
. Similarly, the Caesar cipher uses modulus 26 with the English alphabet.
The key size is too small (only 25 possible keys), making it easily breakable by brute force.
One way to improve security is to use a monoalphabetic cipher that uses an arbitrary substitution. This method involves shuffling the letters in the plaintext by mapping them to a different, random ciphertext letter.
For instance, you can set up a secret phrase or word as the secret key. Let's use "MARKET" as our secret key. The remaining alphabet letters follow the last character of the key (excluding those already used).
Secret key: MARKET
Remaining letters:
M A R K E T B C D F G H I J L N O P Q S U V W X Y Z
The secret key "MARKET" is followed by the rest of the alphabet, excluding letters already used in the key.