Caesar Shift Decoder

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.

Key +5
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
shift-5-places
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).

A cipher wheel is a tool used to help decipher a message encrypted using the Caesar cipher:

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:

FTMF’E AZQ EYMXX EFQB RAD YMZ, AZQ SUMZF XQMB RAD YMZWUZP. ZQUX MDYEFDAZS

From Flowchart to Python Code


Here is the flowchart for our Caesar Shift Decoder:
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

Message #1

FTMF'E AZQ EYMXX EFQB RAD YMZ. AZQ SUMZF XQMB RAD YMZWUZP – ZQUX MDYEFDAZS

Message #2

VYUONCZOF, VYUONCZOF. GUAHCZCWYHN XYMIFUNCIH. VOTT UFXLCH

Message #3

Python Code


Did you like this challenge?

Click on a star to rate it!

Average rating 4.1 / 5. Vote count: 109

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: ,