Question: Cipher ( cipher . py ) Atbash Cipher is a substitution cipher where the encrypted message is obtained by looking up each letter and finding
Cipher cipherpy 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 encoded letter location which is a Y or a calculated position
in the list ex letter to encode B location location encoded letter location
which is a Y
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
initself initializes the alphabet attribute make a list with the letters AZ in it
alternatively make a string with letters AZ in it since a string is a list of characters
encryptmessageself 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 AZ then call the encryptletter 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
decryptmessageself 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
encryptmessage method above.
Cleary
encryptletterself 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.
decryptletterself 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 caesarpy 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 shift value location shift value
encoded letter location 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 shift value location shift value encoded letter location
which is larger than subtract the total number of letters in the alphabet to get the updated
location, which is an A
Example alphabet with a shift value of :
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
Extend the Cipher class.
initself shift passes in caesar ciphers shift value. Call super to initialize
the alphabet, then set the shift value.
encryptletterself 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
