Done pocket enigma breaking by crib
[cipher-training.git] / slides / pocket-enigma-break.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Breaking the pocket enigma</title>
5 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
6 <style type="text/css">
7 /* Slideshow styles */
8 body {
9 font-size: 20px;
10 }
11 h1, h2, h3 {
12 font-weight: 400;
13 margin-bottom: 0;
14 }
15 h1 { font-size: 3em; }
16 h2 { font-size: 2em; }
17 h3 { font-size: 1.6em; }
18 a, a > code {
19 text-decoration: none;
20 }
21 code {
22 -moz-border-radius: 5px;
23 -web-border-radius: 5px;
24 background: #e7e8e2;
25 border-radius: 5px;
26 font-size: 16px;
27 }
28 .plaintext {
29 background: #272822;
30 color: #80ff80;
31 text-shadow: 0 0 20px #333;
32 padding: 2px 5px;
33 }
34 .ciphertext {
35 background: #272822;
36 color: #ff6666;
37 text-shadow: 0 0 20px #333;
38 padding: 2px 5px;
39 }
40 .float-right {
41 float: right;
42 }
43 </style>
44 </head>
45 <body>
46 <textarea id="source">
47
48 # Breaking the Pocket Enigma
49
50 ![centre-aligned Pocket Engima](pocket-enigma-small.jpg)
51
52 Using cribs
53
54 ---
55
56 # Breaking the Pocket Enigma
57
58 A _crib_ is a piece of plaintext we believe to be in the enciphered message.
59
60 This is the way Enigma messages were broken in WWII.
61
62 There are many keys, and doing the naïve Bayes analysis was too expensive.
63
64 The possible keys were filtered by finding the ones that could have produced the crib. These filtered keys could then be checked manually.
65
66 At Bletchley Park, the filtering was done by the Bombes.
67
68 ---
69
70 # Breaking by cribs
71
72 ```
73 Given a message, a wheel spec, a crib, and the location of that crib:
74 Go through each key in turn
75 If the plaintext matches the crib:
76 Add it to the list of possible keys
77 Return the possible keys
78 ```
79
80 ## Example
81 ```python
82 pocket_enigma_break_by_crib('kzpjlzmoga', 1, 'l', 3)
83 ['a', 'j', 'n']
84 ```
85
86 Using wheel 1, the `j` (`ciphertext[3]`) could become `l` if the wheel starts the message on a, j, or n.
87
88 </textarea>
89 <script src="http://gnab.github.io/remark/downloads/remark-0.6.0.min.js" type="text/javascript">
90 </script>
91
92 <script type="text/javascript"
93 src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&delayStartupUntil=configured"></script>
94
95 <script type="text/javascript">
96 var slideshow = remark.create({ ratio: "16:9" });
97
98 // Setup MathJax
99 MathJax.Hub.Config({
100 tex2jax: {
101 skipTags: ['script', 'noscript', 'style', 'textarea', 'pre']
102 }
103 });
104 MathJax.Hub.Queue(function() {
105 $(MathJax.Hub.getAllJax()).map(function(index, elem) {
106 return(elem.SourceElement());
107 }).parent().addClass('has-jax');
108 });
109 MathJax.Hub.Configured();
110 </script>
111 </body>
112 </html>