Skip to content

Instantly share code, notes, and snippets.

@yawara
Created July 13, 2016 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yawara/ca3616248b70d842f5b6363448e688fc to your computer and use it in GitHub Desktop.
Save yawara/ca3616248b70d842f5b6363448e688fc to your computer and use it in GitHub Desktop.
Caesar Crypto
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