Skip to content

Instantly share code, notes, and snippets.

@stevestock
Last active July 22, 2018 01:21
Show Gist options
  • Save stevestock/106b12ca6e353843b74d288be972612b to your computer and use it in GitHub Desktop.
Save stevestock/106b12ca6e353843b74d288be972612b to your computer and use it in GitHub Desktop.
caesar.py
import string
def caesar(text, shift):
intab = string.ascii_letters
outtab = string.ascii_lowercase[shift:] + string.ascii_lowercase[:shift] \
+ string.ascii_uppercase[shift:] + string.ascii_uppercase[:shift]
trantab = str.maketrans(intab, outtab)
return text.translate(trantab)
instr = "Csbjogvdl jt bo ftpufsjd qsphsbnnjoh mbohvbhf opufe gps jut fyusfnf njojnbmjtn. Uif mbohvbhf dpotjtut pg pomz fjhiu tjnqmf dpnnboet boe bo jotusvdujpo qpjoufs. Ju jt eftjhofe up dibmmfohf boe bnvtf qsphsbnnfst, boe xbt opu nbef up cf tvjubcmf gps qsbdujdbm vtf. Ju xbt dsfbufe jo 1993 cz Vscbo Nümmfs. Bozxbzt, uif gmbh jt tufq_ju_vq"
for i in range(1,26):
print(caesar(instr, i))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment