4 <title>Breaking transposition ciphers
</title>
5 <meta http-equiv=
"Content-Type" content=
"text/html; charset=UTF-8"/>
6 <style type=
"text/css">
15 h1 { font-size:
3em; }
16 h2 { font-size:
2em; }
17 h3 { font-size:
1.6em; }
19 text-decoration: none;
22 -moz-border-radius:
5px;
23 -web-border-radius:
5px;
31 text-shadow:
0 0 20px #
333;
37 text-shadow:
0 0 20px #
333;
51 <textarea id=
"source">
53 # Breaking transposition ciphers
55 attack the fort at dawn
64 Generally quite familiar...
66 ## Try all the keys, pick the one that looks most like Englilsh
72 .indexlink[[Index](index.html)]
76 # ...Pick one that looks most like English
78 But the naïve Bayes score will always be the same!
80 * Same letters, just a different order.
82 Score by probability of substrings of letters
84 * Bigrams, trigrams, _n_-grams
90 Given `count_2l.txt` and `count_3l.txt`, counts of bigrams and trigrams in English
92 # Write a function that returns all the _n_-grams for a text, given _n_
93 * Assume the text is already sanitised
95 # Build `P2l`, `P3l` (after `Pl`), `Pbigrams`, `Ptrigrams` (after `Pletters`)
101 What are the possible keys?
105 # Try all the keys...
109 What's the transposition of 'cat'?
119 # Equivalence classes and canonical forms
121 Lots of words yield the same transposition
123 * They're all in the same equivalence class
124 * Only need to test one from the class
126 General idea: if there are different ways to represent something, pick one to make comparisons easier
128 * Canonical form, canonical representation
132 # Finding the transpositions to try
136 if it's a new transposition:
140 What data structure to use to store the transpositions?
144 <script src=
"http://gnab.github.io/remark/downloads/remark-0.6.0.min.js" type=
"text/javascript">
147 <script type=
"text/javascript"
148 src=
"http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&delayStartupUntil=configured"></script>
150 <script type=
"text/javascript">
151 var slideshow = remark.create({ ratio:
"16:9" });
156 skipTags: ['script', 'noscript', 'style', 'textarea', 'pre']
159 MathJax.Hub.Queue(function() {
160 $(MathJax.Hub.getAllJax()).map(function(index, elem) {
161 return(elem.SourceElement());
162 }).parent().addClass('has-jax');
164 MathJax.Hub.Configured();