Skip to content

Commit

Permalink
ROT13
Browse files Browse the repository at this point in the history
  • Loading branch information
t0rr3sp3dr0 committed Oct 29, 2017
1 parent 60a42cc commit 75af340
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions ciphers/rot13.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
def dencrypt(s, n):
out = ''
for c in s:
if c >= 'A' and c <= 'Z':
out += chr(ord('A') + (ord(c) - ord('A') + n) % 26)
elif c >= 'a' and c <= 'z':
out += chr(ord('a') + (ord(c) - ord('a') + n) % 26)
else:
out += c
return out


def main():
s0 = 'HELLO'

s1 = dencrypt(s0, 13)
print(s1) # URYYB

s2 = dencrypt(s1, 13)
print(s2) # HELLO


if __name__ == '__main__':
main()

0 comments on commit 75af340

Please sign in to comment.