History
The Caesar Cipher also known as the Caesar shift cipher is one of the original ciphers created by Julius Caesar of the Roman Empire to protect messages sent to military commanders. What this allowed Caesar to do was protect messages sent to these commanders so that if a messenger was captured they would not be able to identify the message. This is (from what I am aware of) the first cipher ever used by man. It is considered to have been reasonably secure as most people at that time were illiterate and even if they could read it looked like gibberish at first glance. Throughout history there are scattered uses of the Caesar cipher being implemented by criminals or by military squads to prevent people from knowing plans or secrets.
How it works
The Caesar Cipher works by shifting a letter down the alphabet below is an example shift of 3 which was commonly used by Julius Caesar.
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
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 that we have our shift of 3 this is known as our "key". The key is something we can tell someone how to reverse the message without giving the message away. If someone knows the key and the type of cipher that we use they can use that information to decrypt the message. Now we need a message to encrypt. If we want to encrypt the message "Attack the flank" what we would do is smash all the words together and convert the lowercase letters to uppercase to create something like "ATTACKTHEFLANK" and then put it into our cipher letter by letter. The first letter is "a" which maps to the new letter "d" which is the first letter in our ciphertext. our next 2 letters "t" would map to "w" so the first 3 letters of our ciphertext would be "dww". Already you can see it is starting to look like gibberish. Mapping the rest of the message gives you the below message.
ATTACKTHEFLANK
DWWDFNWKHIODQN
This message would be sent to the commander who would have the key and all they would need to do is reverse the shift.
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
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
the first letter "d" maps to "a" and "w" maps to "t" and so on and so forth until the message "ATTACKTHEFLANK" is revealed.
How was it Broken
The Caesar Cipher while it seems very useful had some fatal flaws. The first one is its key length. The key length is what defines how many possible keys there are. While there may be an infinite number of numbers to use there is only a limited number of letters (26). Using modular arithmetic we can see how many unique options we can shift by. Because there are only 26 letters we can use that as our modulus. If "x" is what we want to shift the letters by we can create a formula to identify the shift. in this case the formula is:
(x) mod 26
Modular arithmetic is very simple. All you do is subtract the number given (x) by the limit given (26) repeatedly until x is less then the limit. That final number is your answer. So in this case if x is equal to 35 then we can plug it into the formula as seen here:
(35) mod 26 -> 35-26 = 9 -> (9) mod 26 = 9
Using the above formula we see that a shift of 35 gives us the same key as the shift of 9. Out of all of the shifts only 25 are unique and will not be the same as a previous shift. This means that the keyspace is 25 which is very, very small. In terms of time if someone has an encrypted message and is trying to break it by trying one key at a time (brute force) and each attempt takes 10 mins then that means it will take 250 mins to try every key which is 4 hours and 10 mins. By the time the message was intercepted and the messenger was sent on their way they would have the encryption broken.
The second fatal flaw is that there are no spaces used within the cipher. This leaves the receiver to interpret the message sent and it may not always be accurately represented. An example of this is "ATTACKTHEWALL". This can be interpreted as "ATTACK THE WALL" or "ATTACK THEWALL" by the receiver. If a commander reads this message and is besieging a walled city but is being flanked by a commander named Thewall this can lead to confusion. This scenario is less likely than the first scenario, however, still possible.
Final Thoughts
The Caesar Cipher for its time was a very useful encryption used by the Romans to defend their messages from prying eyes and helped them to maintain military dominance. As flawed as it was it set the benchmark and baseline for future encryption methods that were used in the middle ages and even as far as WWII. The main defeats of the cipher were its weak key length and the potential for messages to be misinterpreted.
I hope this has been informative and I look forward posting more about other encryption methods. Next I will be tackling the Vigenère cipher and detailing its rise and fall in the Middle Ages.