forked from WryHarpy/Enigma-Machine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEncDec with Key choice
More file actions
90 lines (90 loc) · 2.61 KB
/
EncDec with Key choice
File metadata and controls
90 lines (90 loc) · 2.61 KB
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
import evWheels
import whatEnc
whCh1,whCh2,whCh3=input("What wheels will you be using. Please select them in the format of '#-#-#'").split("-")
print(whCh1,whCh2,whCh3)
def encryption():
print('This is the encryption side')
inbound= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -,.'
outbound = evWheels.Wheels.get("W"+whCh1)
word = whatEnc.read()
wordOut = ''
for i in range(len(word)):
count = 0
for j in range(len(inbound)):
if (word[i] == inbound[j]):
count = j
wordOut = wordOut + outbound[count]
print(wordOut)
#Second Wheel
inbound = outbound
outbound = evWheels.Wheels.get("W"+whCh2)
word = wordOut
wordOut = ''
for i in range(len(word)):
count = 0
for j in range(len(inbound)):
if (word[i] == inbound[j]):
count = j
wordOut = wordOut + outbound[count]
print(wordOut)
#Third Wheel
inbound = outbound
outbound = evWheels.Wheels.get("W"+whCh3)
word = wordOut
wordOut = ''
for i in range(len(word)):
count = 0
for j in range(len(inbound)):
if (word[i] == inbound[j]):
count = j
wordOut = wordOut + outbound[count]
print(wordOut)
def decryption():
print('This is the decryption side')
inbound= evWheels.Wheels.get("W"+whCh3)
outbound = evWheels.Wheels.get("W"+whCh2)
word = input("Enter the message you would like to decrypt: ")
wordOut = ''
for i in range(len(word)):
count = 0
for j in range(len(inbound)):
if (word[i] == inbound[j]):
count = j
wordOut = wordOut + outbound[count]
print(wordOut)
#Second Wheel
inbound = outbound
outbound = evWheels.Wheels.get("W"+whCh1)
word = wordOut
wordOut = ''
for i in range(len(word)):
count = 0
for j in range(len(inbound)):
if (word[i] == inbound[j]):
count = j
wordOut = wordOut + outbound[count]
print(wordOut)
#Third Wheel
inbound = outbound
outbound = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz -,.'
word = wordOut
wordOut = ''
for i in range(len(word)):
count = 0
for j in range(len(inbound)):
if (word[i] == inbound[j]):
count = j
wordOut = wordOut + outbound[count]
print(wordOut)
#Calling
answer = '0'
while answer == '0':
print('Press 1 for encrypt, or 2 for decrypt.')
answer = input()
if answer == '1':
encryption()
if answer == '2':
decryption()
else:
answer = '0'
continue