-
Notifications
You must be signed in to change notification settings - Fork 0
/
Decrypter.py
74 lines (62 loc) · 1.95 KB
/
Decrypter.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
print("Добро пожаловать в дешифровщик Цезаря!")
alp = "абвгдеёжзийклмнопрстуфхцчшщъыьэюя"
alp2 = alp
out1, out2, out3, out4 = "","","",""
enc = input("Введите зашифрованный текст: ")
print("\nВариант 1, используются ё и й")
for key in range(0,33):
for l in enc:
if not l.isalpha(): # skip if not letter
out1 += l
continue
pos = alp.find(l)
newp = pos - key
if newp < 0:
newp = len(alp) - abs(newp)
out1 += alp[newp]
print(out1, end="\t")
out1 = ""
print("\n\n\nВариант 2, не используется только ё")
alp = alp.replace("ё", "")
for key in range(0,33):
for l in enc:
if not l.isalpha(): # skip if not letter
out2 += l
continue
pos = alp.find(l)
newp = pos - key
if newp < 0:
newp = len(alp) - abs(newp)
out2 += alp[newp]
print(out2, end="\t")
out2 = ""
print("\n\n\nВариант 3, не используется только й")
alp = alp2
alp = alp.replace("й", "")
for key in range(0,33):
for l in enc:
if not l.isalpha(): # skip if not letter
out3 += l
continue
pos = alp.find(l)
newp = pos - key
if newp < 0:
newp = len(alp) - abs(newp)
out3 += alp[newp]
print(out3, end="\t")
out3 = ""
print("\n\n\nВариант 4, не используются ни ё, ни й")
alp = alp.replace("ё", "")
for key in range(0,33):
for l in enc:
if not l.isalpha(): # skip if not letter
out4 += l
continue
pos = alp.find(l)
newp = pos - key
if newp < 0:
newp = len(alp) - abs(newp)
out4 += alp[newp]
print(out4, end="\t")
out4 = ""
# print("Результат: \'{0}\'".format(encrypted))