jukaukor

Enigmatest.py

Nov 2nd, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. from enigma.machine import EnigmaMachine
  2.  
  3. # setup machine according to specs from a daily key sheet:
  4.  
  5. machine = EnigmaMachine.from_key_sheet(
  6. rotors='II IV V',
  7. reflector='B',
  8. ring_settings=[1, 20, 11],
  9. plugboard_settings='AV BS CG DL FU HZ IN KM OW RX')
  10.  
  11. # set machine initial starting position
  12. machine.set_display('WXC')
  13.  
  14. # decrypt the message key
  15. msg_key = machine.process_text('KCH')
  16.  
  17. # decrypt the cipher text with the unencrypted message key
  18. machine.set_display(msg_key)
  19.  
  20. ciphertext = 'NIBLFMYMLLUFWCASCSSNVHAZ'
  21. plaintext = machine.process_text(ciphertext)
  22.  
  23. print(plaintext)
Advertisement
Add Comment
Please, Sign In to add comment