Python!!! Caesar cipher is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, if the shift is 2, then character 'a' is replaced by 'c', and 'b' is replaced by 'd'. Please complete the following function that creates a codebook with such mapping. (Please use Python to answer using a dictionary in Python. You only need to write at three points in the code. Thank you and look forward to your reply.)
Activity 1 - Creating a codebook
Caesar cipher is a type of substitution cipher in which each letter in the plaintext is replaced by a letter some fixed number of positions down the alphabet. For example, if the shift is 2, then character 'a' is replaced by 'c', and 'b' is replaced by 'd'. Please complete the following function that creates a codebook with such mapping.
In[13]:
alphabet = 'abcdefghijklmnopqrstuvwxyz'
def caesar_codebook(shift):
codebook = {} # INSERT YOUR CODE # 4 lines
def encrypt(msg, cb):
# INSERT YOUR CODE # 4 lines
return s
# TEST CASES
cb = caesar_codebook(5)
s = encrypt('have a great day', cb)
print(s) # afaj f Iwjfy
s = encrypt('adelaide', cb)
print(s) # fijqfnij