Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. print('----------------------------')
  3. print('| Шифр Цезаря. |')
  4. print('| Введите текст: |')
  5. s = input()
  6. s = s.lower()
  7. print('| Введите ключ |')
  8. c = input()
  9. c = int(c)
  10. print('|Шифровать или Дешифровать?|')
  11. res = input()
  12. alphabet = 'абвгдеёжзийклмнопрстуфхцчшщъыьэюя'
  13. result = ''
  14. i = 0
  15. while i < len(s):
  16. j = 0
  17. while j < 34:
  18. if alphabet[j] == s[i]:
  19. if res == "шифр" or res == "1" or res == "Шифровать":
  20. result=result+alphabet[(j+c)%33]
  21. break
  22. elif res == "дешифр" or res == "2" or res == "Дешифровать":
  23. result=result+alphabet[(j-c)%33]
  24. break
  25. j = j+1
  26. i = i +1
  27. print('| Результат |')
  28. print(result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement