Created
February 1, 2011 22:30
-
-
Save gpiancastelli/806851 to your computer and use it in GitHub Desktop.
A basic ROT13 implementation in Python
This file contains 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
#!/usr/bin/env python2.6 | |
import sys | |
from os.path import basename | |
from string import lowercase, uppercase, maketrans | |
if len(sys.argv) != 2: | |
print 'Usage: %s text' % basename(sys.argv[0]) | |
sys.exit(1) | |
ROT = 13 | |
rotated = [letters[ROT:] + letters[:ROT] for letters in (lowercase, uppercase)] | |
table = maketrans(lowercase + uppercase, ''.join(rotated)) | |
print sys.argv[1].translate(table) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment