Question: Cipher ( cipher . py ) Atbash Cipher is a substitution cipher where the encrypted message is obtained by looking up each letter and finding

Cipher (cipher.py) Atbash Cipher is a substitution cipher where the encrypted message is
obtained by looking up each letter and finding the corresponding letter in a reversed alphabet.
The encoded letter can be found in one of two ways, either a parallel list look up (ex. letter to
encode =B, location =1, encoded letter location =1, which is a Y), or a calculated position
in the list (ex. letter to encode =B, location =1,25 location =24, encoded letter location =
24, which is a Y).
012345678910111213141516171819202122232425
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
Z Y X W V U T S R Q P O N M L K J I H G F E D C B A
1.__init__(self) initializes the alphabet attribute make a list with the letters A-Z in it
(alternatively, make a string with letters A-Z in it, since a string is a list of characters).
2. encrypt_message(self, message) pass in the message string. Convert the message
to upper case letters, then loop through the message string one character at a time, if it is
a letter A-Z, then call the encrypt_letter method, otherwise ignore the character. Build
the encryption string using the encrypted letters and ignored characters, and then return it
(ie. leave all spaces, punctuation, and numbers the same, only letters in the string will be
encrypted).
3. decrypt_message(self, message) pass in the message string. Convert the message
to upper case letters, then loop through the message string one character at a time. Build
the decryption string using the decrypted letters in a manner similar to the
encrypt_message method above.
2024 Cleary
4._encrypt_letter(self, letter) passes in one character, letter. Look up the letter
in the alphabet to find its location. Use that location to calculate the position of the
encrypted letter in the manner described above, then return the encrypted letter.
5._decrypt_letter(self, letter) passes in one character, letter. Look up the letter
in the alphabet to find its location. Use that location to calculate the position of the
decrypted letter in the manner described above, then return the decrypted letter.
Casesar (caesar.py) Caesar Cipher this is another substitution cipher where the encrypted
message is found by looking up each letter and finding the corresponding letter in a shifted
alphabet (ex. letter to encode =B, location =1, shift value =3, location + shift value =1+3=
4, encoded letter location =4, which is an E). If the shift value causes the encoded letter to be
past the end of the alphabet, then it should wrap around to the beginning (ex. letter to encode =
X, location =23, shift value =3, location + shift value =23+3=26, encoded letter location =
26, which is larger than 25, subtract the total number of letters in the alphabet to get the updated
location, 2626=0, which is an A).
Example alphabet with a shift value of 3:
012345678910111213141516171819202122232425
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
1. Extend the Cipher class.
2.__init__(self, shift) passes in caesar ciphers shift value. Call super to initialize
the alphabet, then set the shift value.
3._encrypt_letter(self, letter) overridden method passes in one character,
letter. Look up the letter in the alphabet to find its location. Use that location to calculate
the position of the encrypted letter in the manner described above, then return the

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!