Skip to content

Instantly share code, notes, and snippets.

@michielappelman
Created November 7, 2014 16:07
Show Gist options
  • Save michielappelman/90cd7267781e8e67511d to your computer and use it in GitHub Desktop.
Save michielappelman/90cd7267781e8e67511d to your computer and use it in GitHub Desktop.
from enigma.machine import EnigmaMachine
import string
# setup machine according to specs from a daily key sheet:
plug = 'LDERFAS'
for ch1 in string.ascii_uppercase:
for ch2 in string.ascii_uppercase:
for ch3 in string.ascii_uppercase:
for ch4 in [x for x in string.ascii_uppercase if x not in plug]:
machine = EnigmaMachine.from_key_sheet(
rotors='III I II',
reflector='B',
ring_settings='S B E',
plugboard_settings='LD ER FA S' + ch4)
machine.set_display(ch1 + ch2 + ch3)
ciphertext = 'RPVZLYNCQORVUSYUZUBCKNIBKDWZRPFZVLA'
plaintext = machine.process_text(ciphertext)
print plaintext + ' ' + ch1 + ch2 + ch3 + ' S' + ch4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment