A Caesar Shift cipher is a type of mono-alphabetic substitution cipher where each letter of the plain text is shifted a fixed number of places down the alphabet. For example, with a shift of 1, letter A would be replaced by letter B, letter B would be replaced by letter C, and so on. This type of substitution Cipher is named after Julius Caesar, who used it to communicate with his generals.
|Plain text alphabet:||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 alphabet:||F||G||H||I||J||K||L||M||N||O||P||Q||R||S||T||U||V||W||X||Y||Z||A||B||C||D||E|
This type of cipher is a form of symmetric encryption as the same key can be used to both encrypt and decrypt a message. (e.g. If a message is encrypted with a key of +5, it can be decrypted with a key of -5).
Caesar Shift Decoder
The Caesar Shift cipher is not a very secure cipher as it only has 26 different keys. It is hence possible to apply each of the 26 keys to a cipher text to retrieve the plaintext.
The aim of this challenge is to write a Python program to decode a cipher text using all 26 keys. The user will then be able to read the 26 outputs and find the output that correspond to the plaintext.
Here is the cipher text that we will try to decode:
From Flowchart to Python Code
Here is the flowchart for our Caesar Shift Decoder:
To fully understand this algorithm, you will need to understand how ASCII code works. The algorithm above is using the ASCII codes for the uppercase alphabet from letter A (ASCII 65) to letter Z (ASCII 90).
Your task is to write the Python code corresponding to the above flowchart in the trinket box below.
You will then be able to use your Caesar Shift Decoder to decode the following messages:
OVBZAVU, AYHUXBPSPAF IHZL OLYL. AOL LHNSL OHZ SHUKLK. ULPS HYTZAYVUN
FTMF’E AZQ EYMXX EFQB RAD YMZ. AZQ SUMZF XQMB RAD YMZWUZP – ZQUX MDYEFDAZS
VYUONCZOF, VYUONCZOF. GUAHCZCWYHN XYMIFUNCIH. VOTT UFXLCH