The Caesar Cipher
An ancient form of cryptography is to encrypt a message by "rotating" the alphabet forward by three places.
For example to encrypt a message M = ATTACKATDAWN
, each letter will be replaced by the letter that comes three places later.
That is, .
In the cells below, use Python to encrypt M
using the Caesar cipher.
In order to help, I have created a dictionary that might be useful.
As a function ...
Now define a function called caesar_encrypt(M)
which takes a message M
(assumed to be only uppercase Roman letters) and returns the ciphertext resulting from applying the Caesar cipher to M
Decryption
We will now make a new dictionary which is the inverse of the codebook and use it for decryption.
In the cell below, make a new dictionary decodebook
which decrypts your encryption of M
back to the original message.
Decrypting a real message
Your spies intercept the ciphertext message C = 'PHHWDWWKHWRZHUEHIRUHOXQFK'
, sent by Caesar.
What is the original message?