Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from enigma.machine import EnigmaMachine
- # setup machine according to specs from a daily key sheet
- # check Kenngruppen (5 first letters on second message row)
- machine = EnigmaMachine.from_key_sheet(
- rotors='II IV V',
- reflector='B',
- ring_settings='B U L',
- plugboard_settings='AV BS CG DL FU HZ IN KM OW RX')
- # set machine initial starting position
- rotorpositions = input("Anna roottorien alkuasetukset, 3 kirjainta, esim WXC ")
- machine.set_display(rotorpositions)
- enc_key = input("Anna saatu kryptattu message key ")
- # decrypt the encrypted message key
- msg_key = machine.process_text(enc_key)
- print("Message key = ",msg_key)
- # decrypt the cipher text with the unencrypted (decrypted) message key
- machine.set_display(msg_key)
- # keying ciphertext
- ciphertext = input("Anna saatu kryptattu teksti ")
- # decrypt ciphertext
- plaintext = machine.process_text(ciphertext)
- print("plaintext = ",plaintext)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement