-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript5.py
More file actions
42 lines (32 loc) · 1.28 KB
/
script5.py
File metadata and controls
42 lines (32 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from enigma import (Machine, REFLECTOR_OPTIONS,
samplePairs)
code = "HWREISXLGTTBYVXRCWWJAKZDTVZWKBDJPVQYNEQIOTIFX"
cribs = ["FACEBOOK", "TWITTER", "INSTAGRAM", "SNAPCHAT"]
crib2 = ""#"YOUCANFOLLOWMYDOGON"
code_number = "5"
rotors = "V II IV"
ring_settings="06 18 07"
starting_positions = "AJL"
plugboard_pairs = "UG IE PO NX WT"
found = False
for reflector in REFLECTOR_OPTIONS:
for perturbation1 in samplePairs():
for perturbation2 in samplePairs()[1:]:
machine = Machine(rotors=rotors,
reflector=reflector,
ring_setting=ring_settings,
position_setting=starting_positions,
plugboard_mappings=plugboard_pairs,
reflector_mapping_swaps=[perturbation1, perturbation2])
result = machine.encode(code)
if any([crib in result for crib in cribs]) and crib2 in result:
found = (result, perturbation1, perturbation2, reflector)
break
if found:
break
if found:
break
print("code", code_number, "=", result)
print("reflector =", reflector)
print("perturbation1 = ", perturbation1)
print("perturbation2 = ", perturbation2)