Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alf = {'а':1, 'б':2, 'в':3, 'г':4, 'д':5, 'е':6, 'ж':7, 'з':8, 'и':9, 'й':10, 'к':11, 'л':12, 'м':13, 'н':14, 'о':15, 'п':16, 'р':17, 'с':18, 'т':19, 'у':20, 'ф':21, 'х':22, 'ц':23, 'ч':24, 'ш':25, 'щ':26, 'ъ':27, 'ы':28, 'ь':29, 'э':30, 'ю':31, 'я':32, ',':33, '-':34, '!':35, '?':36, '.':37, ' ':38, '_':39}
- def get_key(alf, value):
- for k, v in alf.items():
- if v == value:
- return k
- def index(list, alf):
- index = alf.get(list[i])
- # print(list[i], "- Буква,", index, "- Номер буквы")
- return index
- def correct(ind):
- if ind < 33:
- if (ind%3) == 0:
- ind += 5
- if ind > 32:
- ind -= 32
- elif (ind%3) == 1:
- ind += 10
- if ind > 32:
- ind -= 32
- elif (ind%3) == 2:
- ind += 15
- if ind > 32:
- ind -= 32
- else:
- ind = 39
- return ind
- message = input("Enter message:\n")
- list_message = []
- list_cod = []
- for c in message: # идем по строке
- list_message.append(c) # добавляем буквы в список
- #print(list_message, "\n")
- for i in range(len(list_message)):
- index_s = index(list_message, alf)
- index_m = correct(index_s)
- # print(index_m, "- Номер буквы(", i, ") в конечном сообещении")
- list_cod.append(get_key(alf, index_m))
- message_m = "".join(list_cod)
- print(message, "- Начально сообщение")
- print(message_m, "- Зашифрованное сообщение")
Advertisement
Add Comment
Please, Sign In to add comment