-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
37 lines (25 loc) · 898 Bytes
/
main.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
from keyboard import Keyboard
from plugboard import Plugboard
from rotor import Rotor
from reflector import Reflector
from enigma import Enigma
I = Rotor("EKMFLGDQVZNTOWYHXUSPAIBRCJ", "Q")
II = Rotor("AJDKSIRUXBLHWTMCQGZNPYFVOE", "E")
III = Rotor("BDFHJLCPRTXVZNYEIWGAKMUSQO", "V")
IV = Rotor("ESOVPZJAYQUIRHXLNFTGKDCMWB", "E")
V = Rotor("VZBRGITYUPSDNHLXAWMJQOFECK", "Z")
A = Reflector("EJMZALYXVBWFCRQUONTSPIKHGD")
B = Reflector("YRUHQSLDPXNGOKMIEBFZCWVJAT")
C = Reflector("FVPJIAOYEDRZXWGCTKUQSBNMHL")
KB = Keyboard()
PB = Plugboard(["AT", "BS", "DE", "FM", "IR", "KN", "LZ", "OW", "PV", "HQ"])
ENIGMA = Enigma(B, III, I, IV, PB, KB)
ENIGMA.set_rings((5,23,26))
ENIGMA.set_key("ZIN")
#ENIGMA.r2.show()
message = "ENIGMACIPHERISCOOLRIGHT"
cipher_text =""
for letter in message:
cipher_text = cipher_text +str(ENIGMA.encipher(letter))
print(message)
print(cipher_text)