Created
February 18, 2020 15:05
-
-
Save agu3rra/24f40ae2943aaf1ea08eb862bf2abfa6 to your computer and use it in GitHub Desktop.
A simple snippet for a Caesar cipher in Python
This file contains hidden or 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
message = 'Divide the army in two, advance and outflank them on the right. I will advance on the left flank from the woods getting them by surprise.' | |
message = message.replace(' ','') | |
message = message.replace(',','') | |
message = message.replace('.','') | |
shift_secret = 6 | |
ciphered_message = '' | |
print(message) | |
for character in message: | |
if character.isupper(): | |
ciphered_message += chr((ord(character) + shift_secret - 65) % 26 + 65) | |
else: | |
ciphered_message += chr((ord(character) + shift_secret - 97) % 26 + 97) | |
print(ciphered_message) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment