From: Neil Smith <neil.git@njae.me.uk> Date: Tue, 15 Jul 2014 09:58:37 +0000 (+0100) Subject: Copied over updated slide layout from presentation-slides X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=b2bff955d11597f85c5e1935165a44fb0e5e487e;p=cipher-training.git Copied over updated slide layout from presentation-slides --- diff --git a/slides/affine-break.html b/slides/affine-break.html index ddd8170..8a07978 100644 --- a/slides/affine-break.html +++ b/slides/affine-break.html @@ -36,6 +36,11 @@ color: #ff6666; text-shadow: 0 0 20px #333; padding: 2px 5px; + } + .indexlink { + position: absolute; + bottom: 1em; + left: 1em; } .float-right { float: right; @@ -53,6 +58,12 @@ b | e | h | k | n | q | t | w | z | c | f | i | l | o | r | u | x | a | d | g | --- +layout: true + +.indexlink[[Index](index.html)] + +--- + # Duplicate and extend your `caesar_break()` function * How to cycle through all the keys? diff --git a/slides/affine-encipher.html b/slides/affine-encipher.html index 30f3900..c0f30cb 100644 --- a/slides/affine-encipher.html +++ b/slides/affine-encipher.html @@ -36,6 +36,11 @@ color: #ff6666; text-shadow: 0 0 20px #333; padding: 2px 5px; + } + .indexlink { + position: absolute; + bottom: 1em; + left: 1em; } .float-right { float: right; @@ -56,9 +61,16 @@ An extension of Caesar ciphers * Count the gaps in the letters. --- + +layout: true + +.indexlink[[Index](index.html)] + +--- + # How affine ciphers work -_ciphertext_letter_ =_plaintext_letter_ à a + b +.ciphertext[_ciphertext_letter_] =.plaintext[_plaintext_letter_] à a + b * Convert letters to numbers * Take the total modulus 26 @@ -83,11 +95,11 @@ This is not always defined in modular arithmetic. For instance, 7 à 4 = 28 = 2 Result from number theory: only numbers coprime with _n_ have multiplicative inverses in arithmetic mod _n_. -Another result from number theory: for non-negative integers _a_ and _n_, and there exist unique integers _x_ and _y_ such that _ax_ + _ny_ = gcd(_a_, _b_) +Another result from number theory: for non-negative integers _m_ and _n_, and there exist unique integers _x_ and _y_ such that _mx_ + _ny_ = gcd(_m_, _n_) Coprime numbers have gcd of 1. -_ax_ + _ny_ = 1 mod _n_. But _ny_ mod _n_ = 0, so _ax_ = 1 mod _n_, so _a_ = _x_<sup>-1</sup>. +_mx_ + _ny_ = 1 mod _n_. But _ny_ mod _n_ = 0, so _mx_ = 1 mod _m_, so _m_ = _x_<sup>-1</sup>. Perhaps the algorithm for finding gcds could be useful? diff --git a/slides/aims.html b/slides/aims.html index fcf0c70..1d1da36 100644 --- a/slides/aims.html +++ b/slides/aims.html @@ -37,18 +37,29 @@ text-shadow: 0 0 20px #333; padding: 2px 5px; } + .indexlink { + position: absolute; + bottom: 1em; + left: 1em; + } </style> </head> <body> <textarea id="source"> +layout: true + +.indexlink[[Index](index.html)] + +--- + # Aims Material aimed for two (three?) audiences 1. Teacher CPD 2. In-school resources for children -3. (Outreach resources, mainly Bletchley Park) +3. Outreach resources, mainly Bletchley Park After your suggestions on how to extend these notes to hit these audiences diff --git a/slides/alternative-plaintext-scoring.html b/slides/alternative-plaintext-scoring.html index d6f4aa1..1b2b882 100644 --- a/slides/alternative-plaintext-scoring.html +++ b/slides/alternative-plaintext-scoring.html @@ -36,6 +36,11 @@ color: #ff6666; text-shadow: 0 0 20px #333; padding: 2px 5px; + } + .indexlink { + position: absolute; + bottom: 1em; + left: 1em; } .float-right { float: right; @@ -49,6 +54,12 @@ --- +layout: true + +.indexlink[[Index](index.html)] + +--- + # Back to frequency of letter counts Letter | Count diff --git a/slides/caesar-break.html b/slides/caesar-break.html index 5ea77b9..4d2ebfa 100644 --- a/slides/caesar-break.html +++ b/slides/caesar-break.html @@ -36,6 +36,11 @@ color: #ff6666; text-shadow: 0 0 20px #333; padding: 2px 5px; + } + .indexlink { + position: absolute; + bottom: 1em; + left: 1em; } .float-right { float: right; @@ -51,6 +56,12 @@ --- +layout: true + +.indexlink[[Index](index.html)] + +--- + # Human vs Machine Slow but clever vs Dumb but fast @@ -93,6 +104,8 @@ What does English look like? How do we define "closeness"? +## Here begineth the yak shaving + --- # What does English look like? @@ -154,6 +167,7 @@ open() * Count them ```python import collections +collections.Counter() ``` Create the `language_models.py` file for this. @@ -279,7 +293,7 @@ Use `logger.debug()`, `logger.info()`, etc. to log a message. --- -# How much ciphertext do we need? +# Homework: how much ciphertext do we need? ## Let's do an experiment to find out @@ -289,6 +303,18 @@ Use `logger.debug()`, `logger.info()`, etc. to log a message. 4. Score 1 point if `caesar_cipher_break()` recovers the correct key 5. Repeat many times and with many plaintext lengths +```python +import csv + +def show_results(): + with open('caesar_break_parameter_trials.csv', 'w') as f: + writer = csv.DictWriter(f, ['name'] + message_lengths, + quoting=csv.QUOTE_NONNUMERIC) + writer.writeheader() + for scoring in sorted(scores.keys()): + scores[scoring]['name'] = scoring + writer.writerow(scores[scoring]) +``` </textarea> <script src="http://gnab.github.io/remark/downloads/remark-0.6.0.min.js" type="text/javascript"> diff --git a/slides/caesar-encipher.html b/slides/caesar-encipher.html index 3bc519c..4ef1d34 100644 --- a/slides/caesar-encipher.html +++ b/slides/caesar-encipher.html @@ -37,6 +37,11 @@ text-shadow: 0 0 20px #333; padding: 2px 5px; } + .indexlink { + position: absolute; + bottom: 1em; + left: 1em; + } </style> </head> <body> @@ -50,6 +55,12 @@ Letter-by-letter enciphering --- +layout: true + +.indexlink[[Index](index.html)] + +--- + # Enciphering and deciphering ## Arithmetic on letters diff --git a/slides/further-work.html b/slides/further-work.html index 9d217af..34059f8 100644 --- a/slides/further-work.html +++ b/slides/further-work.html @@ -36,6 +36,11 @@ color: #ff6666; text-shadow: 0 0 20px #333; padding: 2px 5px; + } + .indexlink { + position: absolute; + bottom: 1em; + left: 1em; } .float-right { float: right; @@ -45,6 +50,13 @@ <body> <textarea id="source"> + +layout: true + +.indexlink[[Index](index.html)] + +--- + # Taking this further diff --git a/slides/index.html b/slides/index.html index 8dfb4e1..254581e 100644 --- a/slides/index.html +++ b/slides/index.html @@ -36,6 +36,11 @@ color: #ff6666; text-shadow: 0 0 20px #333; padding: 2px 5px; + } + .indexlink { + position: absolute; + bottom: 1em; + left: 1em; } .float-right { float: right; diff --git a/slides/keyword-break.html b/slides/keyword-break.html index 49160bb..08013f3 100644 --- a/slides/keyword-break.html +++ b/slides/keyword-break.html @@ -36,6 +36,11 @@ color: #ff6666; text-shadow: 0 0 20px #333; padding: 2px 5px; + } + .indexlink { + position: absolute; + bottom: 1em; + left: 1em; } .float-right { float: right; @@ -53,6 +58,12 @@ k | e | y | w | o | r | d | a | b | c | f | g | h | i | j | l | m | n | p | q | --- +layout: true + +.indexlink[[Index](index.html)] + +--- + # Duplicate and extend your `affine_break()` function * How to cycle through all the keys? What _are_ all the keys? diff --git a/slides/keyword-encipher.html b/slides/keyword-encipher.html index 168bb5f..be90c68 100644 --- a/slides/keyword-encipher.html +++ b/slides/keyword-encipher.html @@ -36,6 +36,11 @@ color: #ff6666; text-shadow: 0 0 20px #333; padding: 2px 5px; + } + .indexlink { + position: absolute; + bottom: 1em; + left: 1em; } .float-right { float: right; @@ -55,6 +60,12 @@ k | e | y | w | o | r | d | a | b | c | f | g | h | i | j | l | m | n | p | q | --- +layout: true + +.indexlink[[Index](index.html)] + +--- + # The cipher * Still character-by-character substitution, still monosubstitution. @@ -116,7 +127,7 @@ Use Python 3.4's `Enum` ```python from enum import Enum -class Keyword_wrap_alphabet(Enum): +class KeywordWrapAlphabet(Enum): from_a = 1 from_last = 2 from_largest = 3 diff --git a/slides/pocket-enigma-break.html b/slides/pocket-enigma-break.html index 2592042..f798a50 100644 --- a/slides/pocket-enigma-break.html +++ b/slides/pocket-enigma-break.html @@ -36,6 +36,11 @@ color: #ff6666; text-shadow: 0 0 20px #333; padding: 2px 5px; + } + .indexlink { + position: absolute; + bottom: 1em; + left: 1em; } .float-right { float: right; @@ -53,6 +58,12 @@ Using cribs --- +layout: true + +.indexlink[[Index](index.html)] + +--- + # Breaking the Pocket Enigma A _crib_ is a piece of plaintext we believe to be in the enciphered message. diff --git a/slides/pocket-enigma-encipher.html b/slides/pocket-enigma-encipher.html index b569911..c89ebaf 100644 --- a/slides/pocket-enigma-encipher.html +++ b/slides/pocket-enigma-encipher.html @@ -36,6 +36,11 @@ color: #ff6666; text-shadow: 0 0 20px #333; padding: 2px 5px; + } + .indexlink { + position: absolute; + bottom: 1em; + left: 1em; } .float-right { float: right; @@ -53,6 +58,12 @@ Stateful cipher --- +layout: true + +.indexlink[[Index](index.html)] + +--- + # Pocket Enigma Emulates the Enigma machine from WWII diff --git a/slides/transposition-break.html b/slides/transposition-break.html index 9077c12..76c4f56 100644 --- a/slides/transposition-break.html +++ b/slides/transposition-break.html @@ -36,6 +36,11 @@ color: #ff6666; text-shadow: 0 0 20px #333; padding: 2px 5px; + } + .indexlink { + position: absolute; + bottom: 1em; + left: 1em; } .float-right { float: right; @@ -62,6 +67,12 @@ Generally quite familiar... --- +layout: true + +.indexlink[[Index](index.html)] + +--- + # ...Pick one that looks most like English But the naïve Bayes score will always be the same! diff --git a/slides/transposition-encipher.html b/slides/transposition-encipher.html index af03f75..025f09a 100644 --- a/slides/transposition-encipher.html +++ b/slides/transposition-encipher.html @@ -36,6 +36,11 @@ color: #ff6666; text-shadow: 0 0 20px #333; padding: 2px 5px; + } + .indexlink { + position: absolute; + bottom: 1em; + left: 1em; } .float-right { float: right; @@ -58,6 +63,12 @@ --- +layout: true + +.indexlink[[Index](index.html)] + +--- + # Transposition ciphers Rather than changing symbols (substitution ciphers), diff --git a/slides/word-segmentation.html b/slides/word-segmentation.html index 16fcb0a..35721ab 100644 --- a/slides/word-segmentation.html +++ b/slides/word-segmentation.html @@ -36,6 +36,11 @@ color: #ff6666; text-shadow: 0 0 20px #333; padding: 2px 5px; + } + .indexlink { + position: absolute; + bottom: 1em; + left: 1em; } .float-right { float: right; @@ -54,6 +59,12 @@ --- +layout: true + +.indexlink[[Index](index.html)] + +--- + # The problem Ciphertext is re-split into groups to hide word bounaries.