SHARE
TWEET

Criptografia

a guest Jan 23rd, 2020 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python3.7
  2. # -*- coding: utf-8
  3. '''
  4. Critografia ROT13
  5. @author: aihua.sun
  6. Reescrito por Dalilo Sérgio Gomes Rosas
  7. '''
  8. op = 0
  9. print('''
  10. /$$$$$$$   /$$$$$$  /$$$$$$$$  /$$    /$$$$$$
  11. | $$__  $$ /$$__  $$|__  $$__//$$$$   /$$__  $$
  12. | $$  \ $$| $$  \ $$   | $$  |_  $$  |__/  \ $$
  13. | $$$$$$$/| $$  | $$   | $$    | $$     /$$$$$/
  14. | $$__  $$| $$  | $$   | $$    | $$    |___  $$
  15. \033[31m| $$  \ $$| $$  | $$   | $$    | $$   /$$  \ $$
  16. | $$  | $$|  $$$$$$/   | $$   /$$$$$$|  $$$$$$/
  17. |__/  |__/ \______/    |__/  |______/ \______/ \033[0;0m
  18.  
  19. ''')
  20. print('\033[33m[          Dalilo Sérgio Gomes Rosas          ]\033[0m')
  21. print('\n')
  22. LOWER_LETTERS = [chr(x) for x in range(97, 123)]
  23. UPPER_LETTERS = [chr(x) for x in range(65, 91)]
  24. while op != 3:
  25.     print('Escola uma das opções:\n\n1 - Descriptografar\n2 - Nova descriptografia\n3 - Sair\n\n')
  26.     op = int(input('[Opção]>>> '))
  27.  
  28.     if op == 1 or op == 2:
  29.         try:
  30.             def rot13():
  31.                 sourceString = input("Entre com a string ROT-13: ")
  32.                 resultString = ""
  33.                 for char in sourceString:
  34.                     if char.isupper():
  35.                         resultString += encrypt(char, UPPER_LETTERS)
  36.                     elif char.islower():
  37.                         resultString += encrypt(char, LOWER_LETTERS)
  38.                     else:
  39.                         resultString += char
  40.                 print(f'O resultado da descriptografia ROT-13 é: {resultString}')
  41.                 print('\n')
  42.             def encrypt(char, letterList):
  43.                 resultchar = ''
  44.                 originalIndex = letterList.index(char)
  45.                 newIndex = originalIndex + 13
  46.                 resultchar += letterList[newIndex % len(letterList)]
  47.                 return resultchar
  48.             if __name__ == '__main__':
  49.                 rot13()
  50.         except KeyboardInterrupt:
  51.             print('\nInterrompido pelo usuário!\n')
  52.  
  53. if op == 3:
  54.         print('\nFim... Volte sempre!\n\n')
  55. else:
  56.         print('\n\nOpção inválida, tente novamente.\n')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top