Skip to content

Instantly share code, notes, and snippets.

@inaz2
Created June 9, 2014 06:10
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 inaz2/9a1abd63abbf1807058b to your computer and use it in GitHub Desktop.
Save inaz2/9a1abd63abbf1807058b to your computer and use it in GitHub Desktop.
perform rot0 -- rot25
$ echo -n 'hello world' | python rot.py
hello world
ifmmp xpsme
jgnnq yqtnf
khoor zruog
lipps asvph
mjqqt btwqi
nkrru cuxrj
olssv dvysk
pmttw ewztl
qnuux fxaum
rovvy gybvn
spwwz hzcwo
tqxxa iadxp
uryyb jbeyq
vszzc kcfzr
wtaad ldgas
xubbe mehbt
yvccf nficu
zwddg ogjdv
axeeh phkew
byffi qilfx
czggj rjmgy
dahhk sknhz
ebiil tloia
fcjjm umpjb
gdkkn vnqkc
import sys
def rot(s, n):
s = bytearray(s)
for i, c in enumerate(s):
if 0x41 <= c <= 0x5a:
s[i] = ((c-0x41+n) % 0x1a) + 0x41
elif 0x61 <= c <= 0x7a:
s[i] = ((c-0x61+n) % 0x1a) + 0x61
return s
data = sys.stdin.read()
for n in xrange(26):
print rot(data, n)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment