/ Published in: Python
This function takes 2 arguments, first is the string to be encoded (or decoded) the second is optional and can be used to change the rotation amount to something other than 13.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
def rot(s, n=13): r = "" for c in s: cc = c if cc.isalpha(): cc = cc.lower() o = ord(cc) ro = (o+n) % 122 if ro == 0: ro = 122 if ro < 97: ro += 96 cc = chr(ro) r = ''.join((r,cc)) return r