Skip to content

Instantly share code, notes, and snippets.

@olecksamdr
Last active May 2, 2022 09:00
Show Gist options
  • Save olecksamdr/4dbc326d0cbfef02847fee0374d8f724 to your computer and use it in GitHub Desktop.
Save olecksamdr/4dbc326d0cbfef02847fee0374d8f724 to your computer and use it in GitHub Desktop.
Шифр Цезаря (caesar cipher) на python
abc = 'абвгґдеєжзиіїйклмнопрстуфхцчшщьюя'
msg = input('Введіть повідомлення: ')
key = int(input('Введіть зміщення: '))
msg = msg.lower()
count = len(abc)
for letter in msg:
idx = abc.index(letter)
new_idx = (idx + key) % count
print(abc[new_idx], end='')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment