Skip to content

Instantly share code, notes, and snippets.

@ricexen
Created November 19, 2018 07:12
Show Gist options
  • Save ricexen/63557eab47add120a36b370ca6de85af to your computer and use it in GitHub Desktop.
Save ricexen/63557eab47add120a36b370ca6de85af to your computer and use it in GitHub Desktop.
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