Skip to content

Instantly share code, notes, and snippets.

@bentappin
Created May 1, 2012 10:12
Show Gist options
  • Save bentappin/2567007 to your computer and use it in GitHub Desktop.
Save bentappin/2567007 to your computer and use it in GitHub Desktop.
Caesar shift
import string
def caesar_shift(s, shift):
t = string.maketrans(
string.lowercase + string.uppercase,
string.lowercase[shift:] + string.lowercase[:shift] + string.uppercase[shift:] + string.uppercase[:shift]
)
return s.translate(t)
def rot_13(s):
return caesar_shift(s, 13)
hi = 'Uryyb, Jbeyq!'
print rot_13(hi)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment