# Breaking the Pocket Enigma ![centre-aligned Pocket Engima](pocket-enigma-small.jpg) Using cribs --- # Breaking the Pocket Enigma A _crib_ is a piece of plaintext we believe to be in the enciphered message. This is the way Enigma messages were broken in WWII. There are many keys, and doing the naïve Bayes analysis was too expensive. The possible keys were filtered by finding the ones that could have produced the crib. These filtered keys could then be checked manually. At Bletchley Park, the filtering was done by the Bombes. --- # Breaking by cribs ``` Given a message, a wheel spec, a crib, and the location of that crib: Go through each key in turn If the plaintext matches the crib: Add it to the list of possible keys Return the possible keys ``` ## Example ```python pocket_enigma_break_by_crib('kzpjlzmoga', 1, 'l', 3) ['a', 'j', 'n'] ``` Using wheel 1, the `j` (`ciphertext[3]`) could become `l` if the wheel starts the message on a, j, or n.