Created
November 16, 2008 08:04
-
-
Save gvx/25431 to your computer and use it in GitHub Desktop.
A ROT13 function for Pyton.
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
#By Robin Wellner (gvx) | |
#I hereby waive copyright and related or neighboring rights to this work | |
#See the Creative Commons Zero Waiver at <http://creativecommons.org/publicdomain/zero/1.0/> | |
def rotn(intext, n): | |
outtext = [] | |
for char in intext: | |
if 65 <= ord(char) < (65+26): | |
char = chr(((ord(char) - 65) +n) % 26 + 65) | |
elif 97 <= ord(char) < (97+26): | |
char = chr(((ord(char) - 97) +n) % 26 + 97) | |
outtext.append(char) | |
return ''.join(outtext) | |
def rot13(intext): | |
return rotn(intext, 13) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment