-
Notifications
You must be signed in to change notification settings - Fork 0
/
enigma3.py
183 lines (145 loc) · 3.53 KB
/
enigma3.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# Code Creator THE ULTIMATE
import random
while True:
alpha = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
beta = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
delta = """abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*(),./<>?-_=+\|]}[{:;"'¡™£¢∞§¶•ªº–≠œ∑´®†¥¨ˆøπ“‘«åß∂ƒ©˙∆˚¬…æΩ≈ç√∫˜µ≤≥÷`⁄€‹›fifl‡°·‚—±Œ„´‰ˇÁ¨Ø∏”»ÍνÓÔÒÚƸ˛Ç◊ı˜Â¯˘¿"""
echo = ""
fox = ""
golf = ""
lett = ""
char = ""
key1 = ""
key2 = ""
arr = []
num = 0
num2 = 0
num3 = 0
num4 = 0
xy = 0
print ("")
print ("What do you want to do?")
print ("- Encode")
print ("- Decode")
print ("")
a = input()
if a == "Back":
break
elif a == "Encode":
print("")
print("What message would you like to encode?")
message = str(input())
print("")
print("What key word would like to use?")
key1 = str(input())
print("")
print("What other key word would like to use?")
key2 = str(input())
result = ""
if message == "Back":
break
else:
for letter in key1.split():
beta = beta.strip(letter)
beta = key1 + beta
for character in message:
if character == " ":
fox += " "
elif alpha.find(character) == -1:
fox += character
else:
num = alpha.find(character)
character = beta[num]
fox += character
print(fox)
num = 0
for letter in key2:
num = alpha.find(letter)
arr.append(num)
num = 0
for character in fox:
if character == " ":
golf += " "
elif alpha.find(character) == -1:
golf += character
else:
num = alpha.find(character) + 1
num2 = xy % len(key2)
num3 = arr[num2]
num4 = (num3 + num) % len(alpha)
lett = alpha[num4]
golf += lett
xy += 1
print(golf)
for character in golf:
if character == " ":
for i in range(len(delta) + 2):
lett = delta[random.randint(0,len(delta) - 1)]
char += lett
lett = ""
else:
num = delta.find(character)
for i in range(num + 1):
lett = delta[random.randint(0,len(delta) - 1)]
char += lett
lett = ""
result += char + " "
char = ""
print("")
print(result)
elif a == "Decode":
print("")
print("What message would you like to decode?")
message = str(input())
print("")
print("What key word would like to use?")
key1 = str(input())
print("")
print("What other key word would like to use?")
key2 = str(input())
result = ""
if message == "Back":
break
else:
for word in message.split():
if len(word) >= len(delta) + 1:
fox += " "
elif len(word) - 1 <= len(delta):
char = delta[len(word) - 1]
fox += char
char = ""
print(fox)
num = 0
for letter in key2:
num = alpha.find(letter)
arr.append(num)
num = 0
for character in fox:
if character == " ":
golf += " "
elif alpha.find(character) == -1:
golf += character
else:
num = alpha.find(character) - 1
num2 = xy % len(key2)
num3 = arr[num2]
num4 = (num - num3) % len(alpha)
lett = alpha[num4]
golf += lett
xy += 1
num = 0
print(golf)
for letter in key1.split():
beta = beta.strip(letter)
beta = key1 + beta
for character in golf:
if character == " ":
result += " "
elif beta.find(character) == -1:
result += character
else:
num = beta.find(character)
character = alpha[num]
result += character
print("")
print(result)