Advertisement
jukaukor

enigmadecrypt.py

Jul 23rd, 2021
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. from enigma.machine import EnigmaMachine
  2.  
  3. # setup machine according to specs from a daily key sheet
  4. # check Kenngruppen (5 first letters on second message row)
  5.  
  6. machine = EnigmaMachine.from_key_sheet(
  7. rotors='II IV V',
  8. reflector='B',
  9. ring_settings='B U L',
  10. plugboard_settings='AV BS CG DL FU HZ IN KM OW RX')
  11.  
  12. # set machine initial starting position
  13. rotorpositions = input("Anna roottorien alkuasetukset, 3 kirjainta, esim WXC ")
  14. machine.set_display(rotorpositions)
  15. enc_key = input("Anna saatu kryptattu message key ")
  16. # decrypt the encrypted message key
  17. msg_key = machine.process_text(enc_key)
  18. print("Message key = ",msg_key)
  19.  
  20. # decrypt the cipher text with the unencrypted (decrypted) message key
  21. machine.set_display(msg_key)
  22.  
  23. # keying ciphertext
  24. ciphertext = input("Anna saatu kryptattu teksti ")
  25. # decrypt ciphertext
  26. plaintext = machine.process_text(ciphertext)
  27.  
  28. print("plaintext = ",plaintext)
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement