1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
from enigma.machine import EnigmaMachine
# setup machine according to specs from a daily key sheet:
machine = EnigmaMachine.from_key_sheet(
rotors='II IV V',
reflector='B',
ring_settings=[1, 20, 11],
plugboard_settings='AV BS CG DL FU HZ IN KM OW RX')
# set machine initial starting position
machine.set_display('WXC')
# decrypt the message key
msg_key = machine.process_text('KCH')
# decrypt the cipher text with the unencrypted message key
machine.set_display(msg_key)
ciphertext = 'NIBLFMYMLLUFWCASCSSNVHAZ'
plaintext = machine.process_text(ciphertext)
print(plaintext)
|