Created
November 19, 2018 07:12
-
-
Save ricexen/63557eab47add120a36b370ca6de85af to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" | |
crypted_message = "KLZWSHGHTPLUAV" | |
def cesar_alphabet(alphabet, positions): | |
if(positions >= len(alphabet)): | |
return alphabet | |
else: | |
return alphabet[positions:] + alphabet[:positions] | |
def decrypt(crypted_message, alphabet, crypted_alphabet): | |
message = '' | |
for crypted_message_letter in crypted_message: | |
for le, crypted_alphabet_letter in enumerate(crypted_alphabet): | |
if(crypted_alphabet_letter == crypted_message_letter): | |
message += alphabet[le] | |
return message | |
crypted_alphabet = cesar_alphabet(alphabet, 7) | |
message = decrypt(crypted_message, alphabet, crypted_alphabet) | |
print(alphabet, crypted_alphabet, message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment