diff --git a/Ciphers/rot13.py b/Ciphers/rot13.py new file mode 100644 index 0000000..966603d --- /dev/null +++ b/Ciphers/rot13.py @@ -0,0 +1,21 @@ +#rot13 +OFFSET_LOWER = ord('a') +OFFSET_UPPER = ord('A') + +def rot13(text): + rot13_text = '' + for i in range(len(text)): + ch = text[i] + if ch.isalpha(): + if(ch.islower()): + offset = OFFSET_LOWER + else: + offset = OFFSET_UPPER + rot13_text += chr(((ord(ch)-offset+13)%26+offset)) + else: + rot13_text += ch + return rot13_text + +plain_text = input("Enter the string: ") +print(rot13(plain_text)) +print(rot13(rot13(plain_text)))