Created
July 13, 2016 14:39
-
-
Save yawara/ca3616248b70d842f5b6363448e688fc to your computer and use it in GitHub Desktop.
Caesar Crypto
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
import string | |
def caesar(plaintext, shift): | |
alphabet_lower = string.ascii_lowercase | |
alphabet_upper = string.ascii_uppercase | |
alphabet = alphabet_lower + alphabet_upper | |
shifted_alphabet = alphabet_lower[shift:] + alphabet_lower[:shift] + alphabet_upper[shift:] + alphabet_upper[:shift] | |
table = str.maketrans(alphabet, shifted_alphabet) | |
return plaintext.translate(table) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment