-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
21 lines (16 loc) · 855 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from config import Config
from rotor import Rotor
from enigma import Enigma
from reflector import Reflector
from plugboard import Plugboard
settings = Config("abcdefghijklmnopqrstuvwxyz")
rotor1 = Rotor(links="EKMFLGDQVZNTOWYHXUSPAIBRCJ", rotation=0, move_next="r", config=settings)
rotor2 = Rotor(links="AJDKSIRUXBLHWTMCQGZNPYFVOE", rotation=0, move_next="f", config=settings)
rotor3 = Rotor(links="BDFHJLCPRTXVZNYEIWGAKMUSQO", rotation=0, move_next="w", config=settings)
reflector = Reflector("YRUHQSLDPXNGOKMIEBFZCWVJAT", settings)
enigma = Enigma([rotor1, rotor2, rotor3], Plugboard(""), reflector)
#Demostrate the self-inverse nature
string = input("Enter a string to encode: ")
print("After one encoding ", out := enigma.encode(string))
enigma.reset()
print("After resetting the enigma and reapplying ", enigma.encode(out))