Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3.7
- # -*- coding: utf-8
- '''
- Critografia ROT13
- @author: aihua.sun
- Reescrito por Dalilo Sérgio Gomes Rosas
- '''
- op = 0
- print('''
- /$$$$$$$ /$$$$$$ /$$$$$$$$ /$$ /$$$$$$
- | $$__ $$ /$$__ $$|__ $$__//$$$$ /$$__ $$
- | $$ \ $$| $$ \ $$ | $$ |_ $$ |__/ \ $$
- | $$$$$$$/| $$ | $$ | $$ | $$ /$$$$$/
- | $$__ $$| $$ | $$ | $$ | $$ |___ $$
- \033[31m| $$ \ $$| $$ | $$ | $$ | $$ /$$ \ $$
- | $$ | $$| $$$$$$/ | $$ /$$$$$$| $$$$$$/
- |__/ |__/ \______/ |__/ |______/ \______/ \033[0;0m
- ''')
- print('\033[33m[ Dalilo Sérgio Gomes Rosas ]\033[0m')
- print('\n')
- LOWER_LETTERS = [chr(x) for x in range(97, 123)]
- UPPER_LETTERS = [chr(x) for x in range(65, 91)]
- while op != 3:
- print('Escola uma das opções:\n\n1 - Descriptografar\n2 - Nova descriptografia\n3 - Sair\n\n')
- op = int(input('[Opção]>>> '))
- if op == 1 or op == 2:
- try:
- def rot13():
- sourceString = input("Entre com a string ROT-13: ")
- resultString = ""
- for char in sourceString:
- if char.isupper():
- resultString += encrypt(char, UPPER_LETTERS)
- elif char.islower():
- resultString += encrypt(char, LOWER_LETTERS)
- else:
- resultString += char
- print(f'O resultado da descriptografia ROT-13 é: {resultString}')
- print('\n')
- def encrypt(char, letterList):
- resultchar = ''
- originalIndex = letterList.index(char)
- newIndex = originalIndex + 13
- resultchar += letterList[newIndex % len(letterList)]
- return resultchar
- if __name__ == '__main__':
- rot13()
- except KeyboardInterrupt:
- print('\nInterrompido pelo usuário!\n')
- if op == 3:
- print('\nFim... Volte sempre!\n\n')
- else:
- print('\n\nOpção inválida, tente novamente.\n')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement