Pocket enigma only
authorNeil Smith <neil.git@njae.me.uk>
Mon, 14 Jul 2014 17:58:19 +0000 (18:58 +0100)
committerNeil Smith <neil.git@njae.me.uk>
Mon, 14 Jul 2014 17:58:19 +0000 (18:58 +0100)
cipherbreak.py

index b28b763250bd10115545a34a25a86b08c3a634e9..5f2400fefc5d19ee7e59b3090fe8b659633eb1fa 100644 (file)
@@ -407,35 +407,6 @@ def beaufort_frequency_break(message, max_key_length=20, fitness=Pletters):
                                for i in range(1, max_key_length+1)])
     return max(results, key=lambda k: k[1])
 
-
-def pocket_enigma_break_by_crib(message, wheel_spec, crib, crib_position):
-    """Break a pocket enigma using a crib (some plaintext that's expected to
-    be in a certain position). Returns a list of possible starting wheel
-    positions that could produce the crib.
-
-    >>> pocket_enigma_break_by_crib('kzpjlzmoga', 1, 'h', 0)
-    ['a', 'f', 'q']
-    >>> pocket_enigma_break_by_crib('kzpjlzmoga', 1, 'he', 0)
-    ['a']
-    >>> pocket_enigma_break_by_crib('kzpjlzmoga', 1, 'll', 2)
-    ['a']
-    >>> pocket_enigma_break_by_crib('kzpjlzmoga', 1, 'l', 2)
-    ['a']
-    >>> pocket_enigma_break_by_crib('kzpjlzmoga', 1, 'l', 3)
-    ['a', 'j', 'n']
-    >>> pocket_enigma_break_by_crib('aaaaa', 1, 'l', 3)
-    []
-    """
-    pe = PocketEnigma(wheel=wheel_spec)
-    possible_positions = []
-    for p in string.ascii_lowercase:
-        pe.set_position(p)
-        plaintext = pe.decipher(message)
-        if plaintext[crib_position:crib_position+len(crib)] == crib:
-            possible_positions += [p]
-    return possible_positions
-
-
 def plot_frequency_histogram(freqs, sort_key=None):
     x = range(len(freqs.keys()))
     y = [freqs[l] for l in sorted(freqs.keys(), key=sort_key)]