--- /dev/null
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 220,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [],
+ "source": [
+ "from szyfrow.keyword_cipher import *\n",
+ "from szyfrow.column_transposition import *\n",
+ "from szyfrow.vigenere import *\n",
+ "from szyfrow.support.text_prettify import *\n",
+ "from szyfrow.polybius import *\n",
+ "from szyfrow.caesar import *\n",
+ "import collections\n",
+ "from itertools import *"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 150,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [],
+ "source": [
+ "challenge_number = 7\n",
+ "plaintext_a_filename = f'plaintext.{challenge_number}a.txt'\n",
+ "plaintext_b_filename = f'plaintext.{challenge_number}b.txt'\n",
+ "ciphertext_a_filename = f'ciphertext.{challenge_number}a.txt'\n",
+ "ciphertext_b_filename = f'ciphertext.{challenge_number}b.txt'"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 151,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [],
+ "source": [
+ "ca = open(ciphertext_a_filename).read()\n",
+ "sca = sanitise(ca)\n",
+ "rsca = cat(reversed(sca))\n",
+ "cb = open(ciphertext_b_filename).read()\n",
+ "scb = cat(c for c in cb if c in (string.ascii_letters + '#+'))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 6,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "triangle \n",
+ "\n",
+ "theattacheddocumentwasinterceptedbyharrysteamwhohavemanagedtoplantabugonthecommunicationlinesoutoftirpitzuferourcryptanalystshaveexaminedtheciphertextandthecasefilesandbelievethatitmayberelatedtothewheatstoneclockcipherdeputyheadofthedivisionhaswrittenabossguidetotheseciphermachinesandwehaveaddedthattothecasefilesharrysteamalsorecoveredascrapofburntpaperfromtheabwehrhqwastewhichcarriesthefollowingmessagewhichwethinkmightbepartoftheplaintexttentialstopthetripwireoptionisalsodeprecatedsinceitismorelikelythattheexplthenavyreportedthatadutchfishingvesselwasimpoundedbythenaziauthoritiesinbremerhaventhecrewweredetainedandnegotiationsareunderwaybetweenthedutchandgermanauthoritiestotrytogetthefishermenandtheirvesselbackbutinthemeantimernpatrolswillwatchoutfortheboatincaseitisinvolvedintheoperationtheairministryhavebeenbriefedonourfindingssofarandhaveemphasisedtheimportanceofprotectingtherdfsystemwhichiamtoldtheycallchainhomevkissympatheticbutthethreeofusarestillworriedaboutthenewagentsembeddedinlondonandwearenotsurehowmuchofathreattheyposeitiscrucialthatwebreaktheattachedciphertextasfastaspossiblesowecanputeffectivecountermeasuresinplaceitistemptingtoarrestalltwentythreespyclistsandaskthemdirectlybutwithoutrevealingtheextentofoursurveillanceandcodebreakingabilityitwillnotbepossibletoprovethattheyhavebrokenthelawsowewouldnotbeabletodetainordeportthemitwouldusuallybebettertowatchandwaitbuttheairministryfeelsthattherisktoourairdefenceistoogreatsoweneedtoactfastifweknewexactlywhenandwheretheyintendedtoattackchainhomethenwemightbeabletoincreasesecuritytopreventitbutagainweriskrevealingourcounterintelligencecapabilitiesharrysuggestedthatwecouldobscureourtracksbyfakingavisitbydignitariestothetargetsitesasacoverstoryforincreasedsecuritybutwecantmaintaintheincreaseforlongwithoutraisingsuspicionsoitiscrucialtodeterminetheirplanswhatevertheabwehrareintendingtheywontwanttheiragentstofallintoourhandsespeciallyafterademolitionsincethatwouldgiveustheexcuseweneedtoarrestthemitwouldbegoodtoknowwhattheyhaveinmindfortheirexfiltrationthingsareveryfinelybalancedifweacttoosoonwegiveawayourcrucialadvantageintheinterceptwarifweacttoolateourenemiescouldseriouslydamageourairdefencecapabilityitisclearthatthingsarecomingtoaheadanditiscrucialthatwecracktheclockcipherassoonaspossiblethefateofthecountryliesinyourhandspearl\n"
+ ]
+ }
+ ],
+ "source": [
+ "key_a, score_a = vigenere_frequency_break(sca, fitness=Ptrigrams)\n",
+ "print(key_a, '\\n')\n",
+ "pa = vigenere_decipher(sca, key_a)\n",
+ "print(pa)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 7,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "the attached document was intercepted by harry steam who have managed to plant a bug on the\n",
+ "communication lines out of tirpitz ufer our crypt analysts have examined the ciphertext and the case\n",
+ "files and believe that it maybe related to the wheatstone clock cipher deputy head of the division\n",
+ "has written a boss guide to these cipher machines and we have added that to the case files harry\n",
+ "steam also recovered a scrap of burnt paper from the abwehr hq waste which carries the following\n",
+ "message which we think might be part of the plaintext tential stop the tripwire option is also\n",
+ "deprecated since it is more likely that the expl the navy reported that a dutch fishing vessel was\n",
+ "impounded by the nazi authorities in bremerhaven the crew were detained and negotiations are\n",
+ "underway between the dutch and german authorities to try to get the fishermen and their vessel back\n",
+ "but in the meantime rn patrols will watch out for the boat in case it is involved in the operation\n",
+ "the air ministry have been briefed on our findings so far and have emphasised the importance of\n",
+ "protecting the rdf system which i am told they call chain home vk is sympathetic but the three of us\n",
+ "are still worried about the new agents embedded in london and we are not sure how much of a threat\n",
+ "they pose it is crucial that we break the attached ciphertext as fast as possible so we can put\n",
+ "effective countermeasures in place it is tempting to arrest all twenty three spy c lists and ask\n",
+ "them directly but without revealing the extent of our surveillance and code breaking ability it will\n",
+ "not be possible to prove that they have broken the law so we would not be able to detain or deport\n",
+ "them it would usually be better to watch and wait but the air ministry feels that the risk to our\n",
+ "air defence is too great so we need to act fast if we knew exactly when and where they intended to\n",
+ "attack chain home then we might be able to increase security to prevent it but again we risk\n",
+ "revealing our counterintelligence capabilities harry suggested that we could obscure our tracks by\n",
+ "faking a visit by dignitaries to the target sites as a coverstory for increased security but we cant\n",
+ "maintain the increase for long without raising suspicion so it is crucial to determine their plans\n",
+ "whatever the abwehr are intending they wont want their agents to fall into our hands especially\n",
+ "after a demolition since that would give us the excuse we need to arrest them it would be good to\n",
+ "know what they have in mind for their exfiltration things are very finely balanced if we act too\n",
+ "soon we giveaway our crucial advantage in the intercept war if we act too late our enemies could\n",
+ "seriously damage our air defence capability it is clear that things are coming to ahead and it is\n",
+ "crucial that we crack the clock cipher as soon as possible the fate of the country lies in your\n",
+ "hands pearl\n"
+ ]
+ }
+ ],
+ "source": [
+ "pa = prettify(vigenere_decipher(sca, key_a))\n",
+ "print(pa)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 236,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "2843"
+ ]
+ },
+ "execution_count": 236,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "open(plaintext_a_filename, 'w').write(pa)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 152,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'tentialstopthetripwireoptionisalsodeprecatedsinceitismorelikelythattheexpl'"
+ ]
+ },
+ "execution_count": 152,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "crib = sanitise(\"tential stop the tripwire option is also deprecated since it is more likely that the expl\")\n",
+ "crib"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 153,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'#+ABCDEFGHIJKLMNOPQRSTUVWXYZ'"
+ ]
+ },
+ "execution_count": 153,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "cat(sorted(set(scb)))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 192,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [],
+ "source": [
+ "p_alpha = string.ascii_lowercase\n",
+ "c_alpha = string.ascii_uppercase + '#+'"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 193,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [],
+ "source": [
+ "cipherstream = zip(cycle(p_alpha), cycle(c_alpha))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 197,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [],
+ "source": [
+ "def decipher_letter(cipher_letter, stream):\n",
+ " stream = dropwhile(lambda p: p[1] != cipher_letter, stream)\n",
+ " stream, temp_stream = tee(stream, 2)\n",
+ " (plain_letter, c) = list(islice(temp_stream, 1))[0]\n",
+ " return (plain_letter, islice(stream, 1, None))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 198,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [],
+ "source": [
+ "def encipher_letter(plain_letter, stream):\n",
+ " stream = dropwhile(lambda p: p[0] != plain_letter, stream)\n",
+ " stream, temp_stream = tee(stream, 2)\n",
+ " (p, cipher_letter) = list(islice(temp_stream, 1))[0]\n",
+ " return (cipher_letter, islice(stream, 1, None))"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 199,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "('b', 'd', 'z', 'b', 'd', 'f', 'h')"
+ ]
+ },
+ "execution_count": 199,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "cipherstream = zip(cycle(p_alpha), cycle(c_alpha))\n",
+ "p1, s1 = decipher_letter('B', cipherstream)\n",
+ "p2, s2 = decipher_letter('D', s1)\n",
+ "p3, s3 = decipher_letter('Z', s2)\n",
+ "p4, s4 = decipher_letter('+', s3)\n",
+ "p5, s5 = decipher_letter('B', s4)\n",
+ "p6, s6 = decipher_letter('D', s5)\n",
+ "p7, s7 = decipher_letter('D', s6)\n",
+ "\n",
+ "p1, p2, p3, p4, p5, p6, p7"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 200,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "('b', 'd')"
+ ]
+ },
+ "execution_count": 200,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "cipherstream = zip(cycle(p_alpha), cycle(c_alpha))\n",
+ "p1, s1 = decipher_letter('B', cipherstream)\n",
+ "p2, s2 = decipher_letter('B', s1)\n",
+ "\n",
+ "p1, p2"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 201,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [],
+ "source": [
+ "def decipher_message(ciphertext, stream):\n",
+ " plaintext = ''\n",
+ " for l in ciphertext:\n",
+ " p, stream = decipher_letter(l, stream)\n",
+ " plaintext += p\n",
+ " return plaintext, stream "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 202,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [],
+ "source": [
+ "def encipher_message(plaintext, stream):\n",
+ " ciphertext = ''\n",
+ " for l in plaintext:\n",
+ " c, stream = encipher_letter(l, stream)\n",
+ " ciphertext += c\n",
+ " return ciphertext, stream "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 203,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'vxnozddfahharfgoxiyg'"
+ ]
+ },
+ "execution_count": 203,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "cipherstream = zip(cycle(p_alpha), cycle(c_alpha))\n",
+ "pb, s = decipher_message(scb[:20], cipherstream)\n",
+ "pb"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 204,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'TCLREWFMNGHLZUHDU+GS+MWX+OURKUALSM+ALN#WSJUREUZMOSBQ#SUXIPKMELYRDWNLZUSJ+V'"
+ ]
+ },
+ "execution_count": 204,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "cipherstream = zip(cycle(p_alpha), cycle(c_alpha))\n",
+ "c_gen, s = encipher_message(crib, cipherstream)\n",
+ "c_gen"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 205,
+ "metadata": {
+ "Collapsed": "false",
+ "scrolled": true
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "[(19, 'T'),\n",
+ " (2, 'C'),\n",
+ " (11, 'L'),\n",
+ " (17, 'R'),\n",
+ " (4, 'E'),\n",
+ " (22, 'W'),\n",
+ " (5, 'F'),\n",
+ " (12, 'M'),\n",
+ " (13, 'N'),\n",
+ " (6, 'G'),\n",
+ " (7, 'H'),\n",
+ " (11, 'L'),\n",
+ " (25, 'Z'),\n",
+ " (20, 'U'),\n",
+ " (7, 'H'),\n",
+ " (3, 'D'),\n",
+ " (20, 'U'),\n",
+ " (27, '+'),\n",
+ " (6, 'G'),\n",
+ " (18, 'S'),\n",
+ " (27, '+'),\n",
+ " (12, 'M'),\n",
+ " (22, 'W'),\n",
+ " (23, 'X'),\n",
+ " (27, '+'),\n",
+ " (14, 'O'),\n",
+ " (20, 'U'),\n",
+ " (17, 'R'),\n",
+ " (10, 'K'),\n",
+ " (20, 'U'),\n",
+ " (0, 'A'),\n",
+ " (11, 'L'),\n",
+ " (18, 'S'),\n",
+ " (12, 'M'),\n",
+ " (27, '+'),\n",
+ " (0, 'A'),\n",
+ " (11, 'L'),\n",
+ " (13, 'N'),\n",
+ " (26, '#'),\n",
+ " (22, 'W'),\n",
+ " (18, 'S'),\n",
+ " (9, 'J'),\n",
+ " (20, 'U'),\n",
+ " (17, 'R'),\n",
+ " (4, 'E'),\n",
+ " (20, 'U'),\n",
+ " (25, 'Z'),\n",
+ " (12, 'M'),\n",
+ " (14, 'O'),\n",
+ " (18, 'S'),\n",
+ " (1, 'B'),\n",
+ " (16, 'Q'),\n",
+ " (26, '#'),\n",
+ " (18, 'S'),\n",
+ " (20, 'U'),\n",
+ " (23, 'X'),\n",
+ " (8, 'I'),\n",
+ " (15, 'P'),\n",
+ " (10, 'K'),\n",
+ " (12, 'M'),\n",
+ " (4, 'E'),\n",
+ " (11, 'L'),\n",
+ " (24, 'Y'),\n",
+ " (17, 'R'),\n",
+ " (3, 'D'),\n",
+ " (22, 'W'),\n",
+ " (13, 'N'),\n",
+ " (11, 'L'),\n",
+ " (25, 'Z'),\n",
+ " (20, 'U'),\n",
+ " (18, 'S'),\n",
+ " (9, 'J'),\n",
+ " (27, '+'),\n",
+ " (21, 'V')]"
+ ]
+ },
+ "execution_count": 205,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "co = [(c_alpha.find(l), l) for i, l in enumerate(c_gen)]\n",
+ "co"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 206,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'VXLKVZXZSZXODRQYFQEM'"
+ ]
+ },
+ "execution_count": 206,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "scb[:20]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 207,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [],
+ "source": [
+ "def offsets(ciphertext):\n",
+ " mappings = {}\n",
+ " letters_seen = 0\n",
+ " offsets = []\n",
+ " for l in ciphertext:\n",
+ " if l not in mappings:\n",
+ " mappings[l] = letters_seen\n",
+ " letters_seen += 1\n",
+ " offsets.append(mappings[l])\n",
+ " return offsets"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 208,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "74"
+ ]
+ },
+ "execution_count": 208,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "crib_offsets = offsets(c_gen)\n",
+ "len(crib_offsets)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 209,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [],
+ "source": [
+ "def plausible_samples(generated_text):\n",
+ " plausible_samples = {}\n",
+ " for i in range(len(scb)):\n",
+ " sample = scb[i:(i + len(crib))]\n",
+ " if len(sample) == len(crib):\n",
+ " ofs = offsets(sample)\n",
+ " if ofs == crib_offsets:\n",
+ " plausible_samples[i] = sample\n",
+ " return plausible_samples"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 210,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'TCLREWFMNGHLZUHDU+GS+MWX+OURKUALSM+ALN#WSJUREUZMOSBQ#SUXIPKMELYRDWNLZUSJ+V'"
+ ]
+ },
+ "execution_count": 210,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "c_gen"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 211,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [],
+ "source": [
+ "def plausible_mapping(crib_output):\n",
+ " mapping = {}\n",
+ " for n, l in crib_output:\n",
+ " if n in mapping:\n",
+ " if mapping[n] != l:\n",
+ " return {}\n",
+ " else:\n",
+ " mapping[n] = l\n",
+ " return mapping"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 212,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "{19: 'T', 2: 'C', 11: 'L'}"
+ ]
+ },
+ "execution_count": 212,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "plausible_mapping(co[:3])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 213,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "{0: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 1: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 2: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 3: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 4: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 5: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 6: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 7: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 8: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 9: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 10: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 11: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 12: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 13: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 14: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 15: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 16: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 17: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 18: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 19: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 20: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 21: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 22: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 23: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 24: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'},\n",
+ " 25: {1026: 'KW+ASVCNDJM+BPM#PLJHLNVZLUPAXPR+HNLR+DIVHGPASPBNUHFOIHPZTYXNS+QA#VD+BPHGLE'}}"
+ ]
+ },
+ "execution_count": 213,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "solutions = {}\n",
+ "for i in range(26):\n",
+ " cipherstream = zip(islice(cycle(p_alpha), i, None),\n",
+ " cycle(c_alpha))\n",
+ " c_gen, s = encipher_message(crib, cipherstream)\n",
+ " solutions[i] = plausible_samples(c_gen)\n",
+ "solutions"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 225,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "12"
+ ]
+ },
+ "execution_count": 225,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "1026 % 26"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 214,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'TCLREWFMNGHLZUHDU+GS+MWX+OURKUALSM+ALN#WSJUREUZMOSBQ#SUXIPKMELYRDWNLZUSJ+V'"
+ ]
+ },
+ "execution_count": 214,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "cipherstream = zip(cycle(p_alpha), cycle(c_alpha))\n",
+ "c_gen0, s = encipher_message(crib, cipherstream)\n",
+ "c_gen0"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 215,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'ABCDEFGHIJKLMNOPQRSTUVWXYZ#+'"
+ ]
+ },
+ "execution_count": 215,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "c_alpha"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 216,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "{19: 'K',\n",
+ " 2: 'W',\n",
+ " 11: '+',\n",
+ " 17: 'A',\n",
+ " 4: 'S',\n",
+ " 22: 'V',\n",
+ " 5: 'C',\n",
+ " 12: 'N',\n",
+ " 13: 'D',\n",
+ " 6: 'J',\n",
+ " 7: 'M',\n",
+ " 25: 'B',\n",
+ " 20: 'P',\n",
+ " 3: '#',\n",
+ " 27: 'L',\n",
+ " 18: 'H',\n",
+ " 23: 'Z',\n",
+ " 14: 'U',\n",
+ " 10: 'X',\n",
+ " 0: 'R',\n",
+ " 26: 'I',\n",
+ " 9: 'G',\n",
+ " 1: 'F',\n",
+ " 16: 'O',\n",
+ " 8: 'T',\n",
+ " 15: 'Y',\n",
+ " 24: 'Q',\n",
+ " 21: 'E'}"
+ ]
+ },
+ "execution_count": 216,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "soln = solutions[0][1026]\n",
+ "alpha_pos = [c_alpha.find(c) for c in c_gen0]\n",
+ "c_alpha_mapped = {}\n",
+ "\n",
+ "for p, c in zip(alpha_pos, soln):\n",
+ " c_alpha_mapped[p] = c\n",
+ "c_alpha_mapped"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 217,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'RFW#SCJMTGX+NDUYOAHKPEVZQBIL'"
+ ]
+ },
+ "execution_count": 217,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "discovered_c_alpha = cat(c_alpha_mapped[i] if i in c_alpha_mapped else ' ' for i in range(28))\n",
+ "discovered_c_alpha"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 218,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "28"
+ ]
+ },
+ "execution_count": 218,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "len(c_alpha_mapped)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 226,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'NDUYOAHKPEVZQBILRFW#SCJMTGX+'"
+ ]
+ },
+ "execution_count": 226,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "rotated_c_alpha = discovered_c_alpha[12:] + discovered_c_alpha[:12]\n",
+ "rotated_c_alpha"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 219,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'wmdxabqdmfuazomftqpdmxfaiqdtmenqqzmbbdahqpmzpagdmsqzfemdqmddmzsuzsfabdahupqkagiuftftqfzfkagdqcgqefqpuzkagdxmefyqeemsqefabftueiuxxnqetubbqpazmpgfotruetuzshqeeqxituotiuxxxmzpmfftqymdetqearraxpxqustmffiamyazrdupmkpqoqynqdfqzftefabftqkiuxxeuszmxftqudmdduhmxnkrxmetuzsftqudzmhusmfuazxustfeuzyadeqoapqfaebqxxagfftqiadprxmfmzpkagiuxxdqbxkfkdqefaburkagnqxuqhqftmfkagmdqnquzsimfotqpftqzmnmzpazftqdqzpqlhagemzpfdkmsmuzmfuzfqdhmxearfiapmkeftdqqpmkeruhqpmkemzpeqhqzpmkeefabpazafmffqybffaymwqoazfmofiuftftqnamfadufeodqiuzmzkaftqdimkefabftqqjbxaeuhqueefmnxqngfetagxpnqfdqmfqpiuftomdqefabftqrgeqemdqftqyaefdqoqzfbdapgofaragddqeqmdotmzpfqotzaxaskpuhueuazmzpomddkfdubxqfdussqdeefabftqktmhqmfuyqdoudogufituotymknqeqfradmzkbqduaprdayftdqqyuzgfqefaeqhqzfqqztagdeefabftqkomzmxeanqfdussqdqpnkmfdubiudqmeeqynxkadftqrgeqyqotmzueyomznqdqbxmoqpiuftmtmzpsdqzmpqyqotmzueyefabeuzoqftqeqotmdsqetmhqnqqzetmbqpradpqyaxufuazgeqiqpazafdqoayyqzpgeuzsftqeqpqhuoqeuzoaynmfeuzoqkagtmhqzaoqdfmuzfkftmfftqotmdsqiuxxxmzpuzmzaduqzfmfuazftmfiuxxymjuyuequfepqefdgofuhqbafqzfumxefabftqfdubiudqabfuazuemxeapqbdqomfqpeuzoqufueyadqxuwqxkftmfftqqjbxaeuhqeiuxxnqpueoahqdqpurftqkmdqmffmotqpfaegotmfdussqdmzpyadqahqdufiagxpnqpurruogxffaoaadpuzmfqftqotmdsqegeuzsegotmpqhuoqefabftqotmdsqeftqyeqxhqemdqeymxxngfftqsqayqfdkarftqbmowmsqiuxxraogeftqnxmefeaufueuybqdmfuhqftmfkaguzefmxxftqeqotmdsqeuzmooadpmzoqiuftftqymzgrmofgdqdeuzefdgofuazeefabuzadpqdfaymjuyueqftqpmymsqfaftqfaiqdeftqqzsuzqqdedqoayyqzpftmfkageqfotmdsqeazftdqqarftqxqsearqmotfaiqdiuftotmdsqefiamzpftdqqeqffaqjbxapquzeqcgqzoqmrfqdotmdsqazqefabeqfmzmppufuazmxpqxmkarftudfkeqoazperadotmdsqfiamzpazqyuzgfqfiqzfkruhqeqoazperadotmdsqftdqqefabmeftqrudefxqsngowxqeufiuxxefdqeeftqrdmyqeaftmfftqetaowimhqarftqeqoazpotmdsqiuxxpuefadfftqegbbadfuzsyqynqdeefabiuftftqftudpqjbxaeuazftqrdmyqetagxpngowxqdqegxfuzsuzftqfafmxpqefdgofuazarftqfaiqdengfftueeqcgqzoqiuxxymwqeufqoxqmdmzoqmzpdqoazefdgofuaztmdpqdfamooaybxuetefabftqpqxmkiuftotmdsqftdqqmxeauzodqmeqeftqxuwqxutaapftmfeaxpuqdeiuxxtmhqmdduhqpazeufquzfuyqfanqomgstfuzftqftudpnxmefuzodqmeuzsoazrgeuazmzpxaeearyadmxqefaburufuebaeeunxqfaoxuynftqfaiqduzmphmzoqarftqpqyaxufuazfasqfyadqpqfmuxqpuymsqearftqmqdumxmzpmybxuruqdoudogufdkftqzftueetagxpnqmffqybfqptaiqhqdurftqdquemzksgmdpbdqeqzoqftqzzadueweetagxpnqfmwqzuzftuedqsmdpefabiqygefxqmhquffakagfapqfqdyuzqftqyaefqrrqofuhqfmdsqferadftqabqdmfuazngfftqpqyaxufuazygeftmbbqzeuygxfmzqagexkmfmxxeufqeradfiadqmeazeefabrudefuzadpqdfabdqhqzfagdqzqykrdaypuedgbfuzsftqabqdmfuazazoqftqkdqmxueqitmfuetmbbqzuzsefabeqoazpiqygefxqmhqzapagnfftmfftueimemzmofarimdefabftqdquemduewftmfftqndufuetsahqdzyqzfymkfdkfadqmotmzmooayyapmfuaziuftftqrgtdqdpuhupuzsftqiadxpnqfiqqzftqudpkuzsqybudqmzpagdevgefmeufuenadzefabftqazxkimkfaqzegdqftmfiqomzfdgxkegbbxmzfftqyuefapdmiftqyuzfamimdftqkomzzafiuzmzpftuebdavqofiuxxnqftqbdahaomfuazftmfqzegdqeftmfftueiuxxtmbbqzefabftqbxmzzuzspuhueuaztmepqfqdyuzqpftmfvmzgmdkrudefiuxxnqftqabfuymxzustfradftqmffmowmeufoauzoupqeiuftmzqiyaazefabftqkegssqefftmfkagebxufuzfafiafqmyefamffmowftqqpygzpefomuefadmzpomzqipazeufqeabqzuzsmoaddupadmxazsftqftmyqeradagdradftoayuzsmuddmupeefabftqegbbadffqmyeetagxpeqfgbxaawagfbaefemfftqfmdsqfeuzmphmzoqarftqmffmoweaftmfkagomzyazufadsgmdpyahqyqzfemzpymwqmruzmxmeeqeeyqzfarftqeqogdufkefabraxxaiuzsftqabqdmfuazftqemnafmsqfqmyeetagxpdqzpqlhagefasqftqdiuftftqegbbadffqmyemfftqtayqarftqxaomxadfesdgbbqotuqruzeagftymxpazefabmgnamfiuxxefmzpnkfabuowkagmxxgbmfftdqqradfkeqhqzvmzgmdkeqoazpiuftmrmxxnmowdqzpqlhagearazqftudfqqzazftqftudfqqzftitqzftqeqmdotetagxptmhqpuqppaizefabkagiuxxzqqpfasmuzmooqeefamnamfombmnxqaromddkuzskagmxxagffayqqfufefabftqdqmdqhqdkymzkruetuzshqeeqxeuzftuezqustnagdtaapmzpiqdqoayyqzpefqmxuzsazqmrfqdftqabqdmfuazefabufyustfrqqxxqeeeqogdqftmfanfmuzuzsazquzmphmzoqtaiqhqdiqygefpaqhqdkftuzsiqomzfabdqhqzfegebuouazuzmphmzoqarftqabqdmfuazefaburftueyueeuazegooqqpeftqzufiuxxnqazxkmymffqdarpmkenqradqftqimdnqsuzemzpkagdftdqqoaydmpqeuzxazpaziuxxbxmkmodgoumxdaxquzoaadpuzmfuzsagduzfqxxusqzoqqrradfenqtuzpqzqykxuzqeefabiqtmhqnqqzimfotuzsmzpxuefqzuzsomdqrgxxkradeuszeftmfftqabqdmfuazoagxptmhqnqqzoaybdayueqpmzpmemdqegxfarftaeqqzcguduqeiqtmhqpueoahqdqpmzqifabeqodqfmsqzokwzaizazxknkftqmodazkynaeeefabiqtmhqnqqzgzmnxqfauzruxfdmfqftuesdagbngfufuewzaizftmfftqxqmpqdueeayqazqiuftftquzufumxtmzpftmfftqkmdqfmwuzsftqxqmpazeuszmxeuzfqxxusqzoqefabftqtqmparftqoagzfqduzfqxxusqzoqndmzotgeqeftqoapqzmyqbqmdxmzpiqiuxxnqymwuzsqhqdkqrradffapueoahqdtqdupqzfufkefabituxqftqpqoxmdmfuazarimdmzpftqpqefdgofuazarftqdprekefqymdqftqoqzfdmxsamxearftueabqdmfuazftqxazpazfdumzsxqiuxxnqwqkfaqzegduzsmrxaiartustcgmxufkuzfqxxusqzoqfauzradyagdnmffxqbxmzeefabiuftagfftqudoayygzuomfuazeiqiuxxnqgzmnxqfayazufadndufuetbxmzebxmouzssqdymzxuhqemfgzzqoqeemdkduewefaburftqdquemzkotmzoqftmfyqynqdearkagdsdagboagxpnqombfgdqpmzpuzfqddasmfqpftqzkagetagxpmnmzpazftqemnafmsqabqdmfuazmzpdqfgdzfafudbuflgrqdefabbdafqofuzsftqupqzfufkarftqfdumzsxquearrmdsdqmfqdxazsfqdyuybadfmzoqfageefabiqomzruzpaftqdimkefabdahawqftqimdngfiqiagxpruzpufyadqpurruogxffaqzegdqftmfiqomziuzufiuftagfmzqfiadwarmsqzfeuzftqombufmxefabftqyueeuaziuxxnqdqsmdpqpmemegooqeeazxkuriqomzsgmdmzfqqftqudemrqfkefabfauzodqmeqftqeqogdufkarftqxazpazfdumzsxqufueodgoumxftmfftqoxaowoubtqdpqhuoqmzpftqmeeaoumfqpoapqnaawedqmotagdxazpazmsqzfeefabftqpqhuoqomzzafnqmxxaiqpfarmxxuzfaqzqyktmzpemzpftueygefnqftqfabbduadufkefaburkagmdqombfgdqpftqzftqoapqnaawoazfmuzuzsftqwqkefaftqoubtqdygefnqpqefdakqpefabufuebduzfqpazebqoumxbmbqdftmfetagxpqmeuxkpueeaxhqngfufomzmxeanquzsqefqpurzqoqeemdkefabitqzgeuzsftqymotuzqfmwqomdqfaqdmeqftqoubtqdmxbtmnqfmrfqdgeqmzpfapqxqfqftqwqkrdayftqoapqnaawfaqzegdqftmfzaazqgeqeftqemyqwqkfiuoqefabftueiuxxmxeadqpgoqftqduewarftqwqkqpoubtqdrmxxuzsuzfaqzqyktmzpeefaburombfgdqmbbqmdeuyyuzqzfftqzgeqazqarftqetmbqpotmdsqefapqefdakftqpqhuoqbdqrqdmnxkngdkuzsuffasqftqdiuftftqotmdsqfauzodqmeqftqpqefdgofuhqbaiqdmzpymwquftmdpqdfadqoazefdgofefabqhqdkazquzftqyahqyqzfiuxxnqbdmkuzsradkagdegooqeemzpkagdoagdmsqmzpoayyufyqzffaftqrmftqdxmzpiuxxnqbdmueqpradqhqdefabkagmdqmzuzebudmfuazfagemxxefabiuetuzskagxgowuzftqruzmxbtmeqarftqabqdmfuazefabkagdegzoxqiuxtqxy'"
+ ]
+ },
+ "execution_count": 219,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "cipherstream = zip(cycle(p_alpha), cycle(discovered_c_alpha))\n",
+ "c_gen, s = decipher_message(scb, cipherstream)\n",
+ "c_gen"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 221,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "(12, -7510.337448308099)"
+ ]
+ },
+ "execution_count": 221,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "caesar_break(c_gen)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 222,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'karloperationcathedraltowerhasbeenapprovedandouragentsarearrangingtoprovideyouwiththetntyourequestedinyourlastmessagestopthiswillbeshippedonadutchfishingvesselwhichwilllandatthemarshesoffoldleighattwoamonfridaydecembertenthstoptheywillsignaltheirarrivalbyflashingtheirnavigationlightsinmorsecodetospelloutthewordflatandyouwillreplytyrestopifyoubelievethatyouarebeingwatchedthenabandontherendezvousandtryagainatintervalsoftwodaysthreedaysfivedaysandsevendaysstopdonotattempttomakecontactwiththeboatoritscrewinanyotherwaystoptheexplosiveisstablebutshouldbetreatedwithcarestopthefusesarethemostrecentproductofourresearchandtechnologydivisionandcarrytripletriggersstoptheyhaveatimercircuitwhichmaybesetforanyperiodfromthreeminutestoseventeenhoursstoptheycanalsobetriggeredbyatripwireassemblyorthefusemechanismcanbereplacedwithahandgrenademechanismstopsincethesechargeshavebeenshapedfordemolitionusewedonotrecommendusingthesedevicesincombatsinceyouhavenocertaintythatthechargewilllandinanorientationthatwillmaximiseitsdestructivepotentialstopthetripwireoptionisalsodeprecatedsinceitismorelikelythattheexplosiveswillbediscoverediftheyareattachedtosuchatriggerandmoreoveritwouldbedifficulttocoordinatethechargesusingsuchadevicestopthechargesthemselvesaresmallbutthegeometryofthepackagewillfocustheblastsoitisimperativethatyouinstallthesechargesinaccordancewiththemanufacturersinstructionsstopinordertomaximisethedamagetothetowerstheengineersrecommendthatyousetchargesonthreeofthelegsofeachtowerwithchargestwoandthreesettoexplodeinsequenceafterchargeonestopsetanadditionaldelayofthirtysecondsforchargetwoandoneminutetwentyfivesecondsforchargethreestopasthefirstlegbucklesitwillstresstheframesothattheshockwaveofthesecondchargewilldistortthesupportingmembersstopwiththethirdexplosiontheframeshouldbuckleresultinginthetotaldestructionofthetowersbutthissequencewillmakesiteclearanceandreconstructionhardertoaccomplishstopthedelaywithchargethreealsoincreasesthelikelihoodthatsoldierswillhavearrivedonsiteintimetobecaughtinthethirdblastincreasingconfusionandlossofmoralestopifitispossibletoclimbthetowerinadvanceofthedemolitiontogetmoredetailedimagesoftheaerialandamplifiercircuitrythenthisshouldbeattemptedhoweverifthereisanyguardpresencethennorisksshouldbetakeninthisregardstopwemustleaveittoyoutodeterminethemosteffectivetargetsfortheoperationbutthedemolitionmusthappensimultaneouslyatallsitesfortworeasonsstopfirstinordertopreventourenemyfromdisruptingtheoperationoncetheyrealisewhatishappeningstopsecondwemustleavenodoubtthatthiswasanactofwarstopthereisariskthatthebritishgovernmentmaytrytoreachanaccommodationwiththefuhrerdividingtheworldbetweentheirdyingempireandoursjustasitisbornstoptheonlywaytoensurethatwecantrulysupplantthemistodrawthemintoawartheycannotwinandthisprojectwillbetheprovocationthatensuresthatthiswillhappenstoptheplanningdivisionhasdeterminedthatjanuaryfirstwillbetheoptimalnightfortheattackasitcoincideswithanewmoonstoptheysuggestthatyousplitintotwoteamstoattacktheedmundstcaistorandcanewdonsitesopeningacorridoralongthethamesforourforthcomingairraidsstopthesupportteamsshouldsetuplookoutpostsatthetargetsinadvanceoftheattacksothatyoucanmonitorguardmovementsandmakeafinalassessmentofthesecuritystopfollowingtheoperationthesabotageteamsshouldrendezvoustogetherwiththesupportteamsatthehomeofthelocalortsgruppechiefinsouthmaldonstopauboatwillstandbytopickyouallupatthreefortysevenjanuarysecondwithafallbackrendezvousofonethirteenonthethirteenthwhenthesearchshouldhavedieddownstopyouwillneedtogainaccesstoaboatcapableofcarryingyouallouttomeetitstopthereareverymanyfishingvesselsinthisneighbourhoodandwerecommendstealingoneaftertheoperationstopitmightfeellesssecurethatobtainingoneinadvancehoweverwemustdoeverythingwecantopreventsuspicioninadvanceoftheoperationstopifthismissionsucceedsthenitwillbeonlyamatterofdaysbeforethewarbeginsandyourthreecomradesinlondonwillplayacrucialroleincoordinatingourintelligenceeffortsbehindenemylinesstopwehavebeenwatchingandlisteningcarefullyforsignsthattheoperationcouldhavebeencompromisedandasaresultofthoseenquirieswehavediscoveredanewtopsecretagencyknownonlybytheacronymbossstopwehavebeenunabletoinfiltratethisgroupbutitisknownthattheleaderissomeonewiththeinitialhandthattheyaretakingtheleadonsignalsintelligencestoptheheadofthecounterintelligencebranchusesthecodenamepearlandwewillbemakingeveryefforttodiscoverheridentitystopwhilethedeclarationofwarandthedestructionoftherdfsystemarethecentralgoalsofthisoperationthelondontrianglewillbekeytoensuringaflowofhighqualityintelligencetoinformourbattleplansstopwithouttheircommunicationswewillbeunabletomonitorbritishplansplacinggermanlivesatunnecessaryriskstopifthereisanychancethatmembersofyourgroupcouldbecapturedandinterrogatedthenyoushouldabandonthesabotageoperationandreturntotirpitzuferstopprotectingtheidentityofthetriangleisoffargreaterlongtermimportancetousstopwecanfindotherwaystoprovokethewarbutwewouldfinditmoredifficulttoensurethatwecanwinitwithoutanetworkofagentsinthecapitalstopthemissionwillberegardedasasuccessonlyifwecanguaranteetheirsafetystoptoincreasethesecurityofthelondontriangleitiscrucialthattheclockcipherdeviceandtheassociatedcodebooksreachourlondonagentsstopthedevicecannotbeallowedtofallintoenemyhandsandthismustbethetopprioritystopifyouarecapturedthenthecodebookcontainingthekeystotheciphermustbedestroyedstopitisprintedonspecialpaperthatshouldeasilydissolvebutitcanalsobeingestedifnecessarystopwhenusingthemachinetakecaretoerasethecipheralphabetafteruseandtodeletethekeyfromthecodebooktoensurethatnooneusesthesamekeytwicestopthiswillalsoreducetheriskofthekeyedcipherfallingintoenemyhandsstopifcaptureappearsimminentthenuseoneoftheshapedchargestodestroythedevicepreferablyburyingittogetherwiththechargetoincreasethedestructivepowerandmakeithardertoreconstructstopeveryoneinthemovementwillbeprayingforyoursuccessandyourcourageandcommitmenttothefatherlandwillbepraisedforeverstopyouareaninspirationtousallstopwishingyouluckinthefinalphaseoftheoperationstopyoursunclewilhelm'"
+ ]
+ },
+ "execution_count": 222,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "caesar_decipher(c_gen, 12)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 229,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'karloperationcathedraltowerhasbeenapprovedandouragentsarearrangingtoprovideyouwiththetntyourequestedinyourlastmessagestopthiswillbeshippedonadutchfishingvesselwhichwilllandatthemarshesoffoldleighattwoamonfridaydecembertenthstoptheywillsignaltheirarrivalbyflashingtheirnavigationlightsinmorsecodetospelloutthewordflatandyouwillreplytyrestopifyoubelievethatyouarebeingwatchedthenabandontherendezvousandtryagainatintervalsoftwodaysthreedaysfivedaysandsevendaysstopdonotattempttomakecontactwiththeboatoritscrewinanyotherwaystoptheexplosiveisstablebutshouldbetreatedwithcarestopthefusesarethemostrecentproductofourresearchandtechnologydivisionandcarrytripletriggersstoptheyhaveatimercircuitwhichmaybesetforanyperiodfromthreeminutestoseventeenhoursstoptheycanalsobetriggeredbyatripwireassemblyorthefusemechanismcanbereplacedwithahandgrenademechanismstopsincethesechargeshavebeenshapedfordemolitionusewedonotrecommendusingthesedevicesincombatsinceyouhavenocertaintythatthechargewilllandinanorientationthatwillmaximiseitsdestructivepotentialstopthetripwireoptionisalsodeprecatedsinceitismorelikelythattheexplosiveswillbediscoverediftheyareattachedtosuchatriggerandmoreoveritwouldbedifficulttocoordinatethechargesusingsuchadevicestopthechargesthemselvesaresmallbutthegeometryofthepackagewillfocustheblastsoitisimperativethatyouinstallthesechargesinaccordancewiththemanufacturersinstructionsstopinordertomaximisethedamagetothetowerstheengineersrecommendthatyousetchargesonthreeofthelegsofeachtowerwithchargestwoandthreesettoexplodeinsequenceafterchargeonestopsetanadditionaldelayofthirtysecondsforchargetwoandoneminutetwentyfivesecondsforchargethreestopasthefirstlegbucklesitwillstresstheframesothattheshockwaveofthesecondchargewilldistortthesupportingmembersstopwiththethirdexplosiontheframeshouldbuckleresultinginthetotaldestructionofthetowersbutthissequencewillmakesiteclearanceandreconstructionhardertoaccomplishstopthedelaywithchargethreealsoincreasesthelikelihoodthatsoldierswillhavearrivedonsiteintimetobecaughtinthethirdblastincreasingconfusionandlossofmoralestopifitispossibletoclimbthetowerinadvanceofthedemolitiontogetmoredetailedimagesoftheaerialandamplifiercircuitrythenthisshouldbeattemptedhoweverifthereisanyguardpresencethennorisksshouldbetakeninthisregardstopwemustleaveittoyoutodeterminethemosteffectivetargetsfortheoperationbutthedemolitionmusthappensimultaneouslyatallsitesfortworeasonsstopfirstinordertopreventourenemyfromdisruptingtheoperationoncetheyrealisewhatishappeningstopsecondwemustleavenodoubtthatthiswasanactofwarstopthereisariskthatthebritishgovernmentmaytrytoreachanaccommodationwiththefuhrerdividingtheworldbetweentheirdyingempireandoursjustasitisbornstoptheonlywaytoensurethatwecantrulysupplantthemistodrawthemintoawartheycannotwinandthisprojectwillbetheprovocationthatensuresthatthiswillhappenstoptheplanningdivisionhasdeterminedthatjanuaryfirstwillbetheoptimalnightfortheattackasitcoincideswithanewmoonstoptheysuggestthatyousplitintotwoteamstoattacktheedmundstcaistorandcanewdonsitesopeningacorridoralongthethamesforourforthcomingairraidsstopthesupportteamsshouldsetuplookoutpostsatthetargetsinadvanceoftheattacksothatyoucanmonitorguardmovementsandmakeafinalassessmentofthesecuritystopfollowingtheoperationthesabotageteamsshouldrendezvoustogetherwiththesupportteamsatthehomeofthelocalortsgruppechiefinsouthmaldonstopauboatwillstandbytopickyouallupatthreefortysevenjanuarysecondwithafallbackrendezvousofonethirteenonthethirteenthwhenthesearchshouldhavedieddownstopyouwillneedtogainaccesstoaboatcapableofcarryingyouallouttomeetitstopthereareverymanyfishingvesselsinthisneighbourhoodandwerecommendstealingoneaftertheoperationstopitmightfeellesssecurethatobtainingoneinadvancehoweverwemustdoeverythingwecantopreventsuspicioninadvanceoftheoperationstopifthismissionsucceedsthenitwillbeonlyamatterofdaysbeforethewarbeginsandyourthreecomradesinlondonwillplayacrucialroleincoordinatingourintelligenceeffortsbehindenemylinesstopwehavebeenwatchingandlisteningcarefullyforsignsthattheoperationcouldhavebeencompromisedandasaresultofthoseenquirieswehavediscoveredanewtopsecretagencyknownonlybytheacronymbossstopwehavebeenunabletoinfiltratethisgroupbutitisknownthattheleaderissomeonewiththeinitialhandthattheyaretakingtheleadonsignalsintelligencestoptheheadofthecounterintelligencebranchusesthecodenamepearlandwewillbemakingeveryefforttodiscoverheridentitystopwhilethedeclarationofwarandthedestructionoftherdfsystemarethecentralgoalsofthisoperationthelondontrianglewillbekeytoensuringaflowofhighqualityintelligencetoinformourbattleplansstopwithouttheircommunicationswewillbeunabletomonitorbritishplansplacinggermanlivesatunnecessaryriskstopifthereisanychancethatmembersofyourgroupcouldbecapturedandinterrogatedthenyoushouldabandonthesabotageoperationandreturntotirpitzuferstopprotectingtheidentityofthetriangleisoffargreaterlongtermimportancetousstopwecanfindotherwaystoprovokethewarbutwewouldfinditmoredifficulttoensurethatwecanwinitwithoutanetworkofagentsinthecapitalstopthemissionwillberegardedasasuccessonlyifwecanguaranteetheirsafetystoptoincreasethesecurityofthelondontriangleitiscrucialthattheclockcipherdeviceandtheassociatedcodebooksreachourlondonagentsstopthedevicecannotbeallowedtofallintoenemyhandsandthismustbethetopprioritystopifyouarecapturedthenthecodebookcontainingthekeystotheciphermustbedestroyedstopitisprintedonspecialpaperthatshouldeasilydissolvebutitcanalsobeingestedifnecessarystopwhenusingthemachinetakecaretoerasethecipheralphabetafteruseandtodeletethekeyfromthecodebooktoensurethatnooneusesthesamekeytwicestopthiswillalsoreducetheriskofthekeyedcipherfallingintoenemyhandsstopifcaptureappearsimminentthenuseoneoftheshapedchargestodestroythedevicepreferablyburyingittogetherwiththechargetoincreasethedestructivepowerandmakeithardertoreconstructstopeveryoneinthemovementwillbeprayingforyoursuccessandyourcourageandcommitmenttothefatherlandwillbepraisedforeverstopyouareaninspirationtousallstopwishingyouluckinthefinalphaseoftheoperationstopyoursunclewilhelm'"
+ ]
+ },
+ "execution_count": 229,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "cipherstream = zip(cycle(p_alpha), cycle(rotated_c_alpha))\n",
+ "p_gen, s = decipher_message(scb, cipherstream)\n",
+ "p_gen"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 233,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [],
+ "source": [
+ "pb = prettify(p_gen)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 235,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "7298"
+ ]
+ },
+ "execution_count": 235,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "open(plaintext_b_filename, 'w').write(pb)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "Collapsed": "false"
+ },
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "jupytext": {
+ "formats": "ipynb,md"
+ },
+ "kernelspec": {
+ "display_name": "Python 3",
+ "language": "python",
+ "name": "python3"
+ },
+ "language_info": {
+ "codemirror_mode": {
+ "name": "ipython",
+ "version": 3
+ },
+ "file_extension": ".py",
+ "mimetype": "text/x-python",
+ "name": "python",
+ "nbconvert_exporter": "python",
+ "pygments_lexer": "ipython3",
+ "version": "3.7.4"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}
--- /dev/null
+---
+jupyter:
+ jupytext:
+ formats: ipynb,md
+ text_representation:
+ extension: .md
+ format_name: markdown
+ format_version: '1.2'
+ jupytext_version: 1.3.4
+ kernelspec:
+ display_name: Python 3
+ language: python
+ name: python3
+---
+
+```python Collapsed="false"
+from szyfrow.keyword_cipher import *
+from szyfrow.column_transposition import *
+from szyfrow.vigenere import *
+from szyfrow.support.text_prettify import *
+from szyfrow.polybius import *
+from szyfrow.caesar import *
+import collections
+from itertools import *
+```
+
+```python Collapsed="false"
+challenge_number = 7
+plaintext_a_filename = f'plaintext.{challenge_number}a.txt'
+plaintext_b_filename = f'plaintext.{challenge_number}b.txt'
+ciphertext_a_filename = f'ciphertext.{challenge_number}a.txt'
+ciphertext_b_filename = f'ciphertext.{challenge_number}b.txt'
+```
+
+```python Collapsed="false"
+ca = open(ciphertext_a_filename).read()
+sca = sanitise(ca)
+rsca = cat(reversed(sca))
+cb = open(ciphertext_b_filename).read()
+scb = cat(c for c in cb if c in (string.ascii_letters + '#+'))
+```
+
+```python Collapsed="false"
+key_a, score_a = vigenere_frequency_break(sca, fitness=Ptrigrams)
+print(key_a, '\n')
+pa = vigenere_decipher(sca, key_a)
+print(pa)
+```
+
+```python Collapsed="false"
+pa = prettify(vigenere_decipher(sca, key_a))
+print(pa)
+```
+
+```python Collapsed="false"
+open(plaintext_a_filename, 'w').write(pa)
+```
+
+```python Collapsed="false"
+crib = sanitise("tential stop the tripwire option is also deprecated since it is more likely that the expl")
+crib
+```
+
+```python Collapsed="false"
+cat(sorted(set(scb)))
+```
+
+```python Collapsed="false"
+p_alpha = string.ascii_lowercase
+c_alpha = string.ascii_uppercase + '#+'
+```
+
+```python Collapsed="false"
+cipherstream = zip(cycle(p_alpha), cycle(c_alpha))
+```
+
+```python Collapsed="false"
+def decipher_letter(cipher_letter, stream):
+ stream = dropwhile(lambda p: p[1] != cipher_letter, stream)
+ stream, temp_stream = tee(stream, 2)
+ (plain_letter, c) = list(islice(temp_stream, 1))[0]
+ return (plain_letter, islice(stream, 1, None))
+```
+
+```python Collapsed="false"
+def encipher_letter(plain_letter, stream):
+ stream = dropwhile(lambda p: p[0] != plain_letter, stream)
+ stream, temp_stream = tee(stream, 2)
+ (p, cipher_letter) = list(islice(temp_stream, 1))[0]
+ return (cipher_letter, islice(stream, 1, None))
+```
+
+```python Collapsed="false"
+cipherstream = zip(cycle(p_alpha), cycle(c_alpha))
+p1, s1 = decipher_letter('B', cipherstream)
+p2, s2 = decipher_letter('D', s1)
+p3, s3 = decipher_letter('Z', s2)
+p4, s4 = decipher_letter('+', s3)
+p5, s5 = decipher_letter('B', s4)
+p6, s6 = decipher_letter('D', s5)
+p7, s7 = decipher_letter('D', s6)
+
+p1, p2, p3, p4, p5, p6, p7
+```
+
+```python Collapsed="false"
+cipherstream = zip(cycle(p_alpha), cycle(c_alpha))
+p1, s1 = decipher_letter('B', cipherstream)
+p2, s2 = decipher_letter('B', s1)
+
+p1, p2
+```
+
+```python Collapsed="false"
+def decipher_message(ciphertext, stream):
+ plaintext = ''
+ for l in ciphertext:
+ p, stream = decipher_letter(l, stream)
+ plaintext += p
+ return plaintext, stream
+```
+
+```python Collapsed="false"
+def encipher_message(plaintext, stream):
+ ciphertext = ''
+ for l in plaintext:
+ c, stream = encipher_letter(l, stream)
+ ciphertext += c
+ return ciphertext, stream
+```
+
+```python Collapsed="false"
+cipherstream = zip(cycle(p_alpha), cycle(c_alpha))
+pb, s = decipher_message(scb[:20], cipherstream)
+pb
+```
+
+```python Collapsed="false"
+cipherstream = zip(cycle(p_alpha), cycle(c_alpha))
+c_gen, s = encipher_message(crib, cipherstream)
+c_gen
+```
+
+```python Collapsed="false"
+co = [(c_alpha.find(l), l) for i, l in enumerate(c_gen)]
+co
+```
+
+```python Collapsed="false"
+scb[:20]
+```
+
+```python Collapsed="false"
+def offsets(ciphertext):
+ mappings = {}
+ letters_seen = 0
+ offsets = []
+ for l in ciphertext:
+ if l not in mappings:
+ mappings[l] = letters_seen
+ letters_seen += 1
+ offsets.append(mappings[l])
+ return offsets
+```
+
+```python Collapsed="false"
+crib_offsets = offsets(c_gen)
+len(crib_offsets)
+```
+
+```python Collapsed="false"
+def plausible_samples(generated_text):
+ plausible_samples = {}
+ for i in range(len(scb)):
+ sample = scb[i:(i + len(crib))]
+ if len(sample) == len(crib):
+ ofs = offsets(sample)
+ if ofs == crib_offsets:
+ plausible_samples[i] = sample
+ return plausible_samples
+```
+
+```python Collapsed="false"
+c_gen
+```
+
+```python Collapsed="false"
+def plausible_mapping(crib_output):
+ mapping = {}
+ for n, l in crib_output:
+ if n in mapping:
+ if mapping[n] != l:
+ return {}
+ else:
+ mapping[n] = l
+ return mapping
+```
+
+```python Collapsed="false"
+
+```
+
+```python Collapsed="false"
+plausible_mapping(co[:3])
+```
+
+```python Collapsed="false"
+solutions = {}
+for i in range(26):
+ cipherstream = zip(islice(cycle(p_alpha), i, None),
+ cycle(c_alpha))
+ c_gen, s = encipher_message(crib, cipherstream)
+ solutions[i] = plausible_samples(c_gen)
+solutions
+```
+
+```python Collapsed="false"
+1026 % 26
+```
+
+```python Collapsed="false"
+cipherstream = zip(cycle(p_alpha), cycle(c_alpha))
+c_gen0, s = encipher_message(crib, cipherstream)
+c_gen0
+```
+
+```python Collapsed="false"
+c_alpha
+```
+
+```python Collapsed="false"
+soln = solutions[0][1026]
+alpha_pos = [c_alpha.find(c) for c in c_gen0]
+c_alpha_mapped = {}
+
+for p, c in zip(alpha_pos, soln):
+ c_alpha_mapped[p] = c
+c_alpha_mapped
+```
+
+```python Collapsed="false"
+discovered_c_alpha = cat(c_alpha_mapped[i] if i in c_alpha_mapped else ' ' for i in range(28))
+discovered_c_alpha
+```
+
+```python Collapsed="false"
+len(c_alpha_mapped)
+```
+
+```python Collapsed="false"
+rotated_c_alpha = discovered_c_alpha[12:] + discovered_c_alpha[:12]
+rotated_c_alpha
+```
+
+```python Collapsed="false"
+cipherstream = zip(cycle(p_alpha), cycle(discovered_c_alpha))
+c_gen, s = decipher_message(scb, cipherstream)
+c_gen
+```
+
+```python Collapsed="false"
+caesar_break(c_gen)
+```
+
+```python Collapsed="false"
+caesar_decipher(c_gen, 12)
+```
+
+```python Collapsed="false"
+cipherstream = zip(cycle(p_alpha), cycle(rotated_c_alpha))
+p_gen, s = decipher_message(scb, cipherstream)
+p_gen
+```
+
+```python Collapsed="false"
+pb = prettify(p_gen)
+```
+
+```python Collapsed="false"
+open(plaintext_b_filename, 'w').write(pb)
+```
+
+```python Collapsed="false"
+
+```
--- /dev/null
+karl operation cathedral tower has been approved and our agents are arranging to provide you with
+the tnt you requested in your last messages top this will be shipped on a dutch fishing vessel which
+will land at the marshes of fold leigh at two am on friday december tenth stop they will signal
+their arrival by flashing their navigation lights in morsecode to spell out the word flat and you
+will reply tyres top if you believe that you are being watched then abandon the rendezvous and try
+again at intervals of two days three days five days and seven days stop do not attempt to make
+contact with the boat or it screw in any other ways top the explosive is stable but should be
+treated with care stop the fuses are the most recent product of our research and technology division
+and carry triple triggers stop they have a timer circuit which maybe set for any period from three
+minutes to seventeen hours stop they can also be triggered by a tripwire assembly or the fuse
+mechanism can be replaced with a hand grenade mechanisms top since these charges have been shaped
+for demolition use we do not recommend using these devices in combat since you have no certainty
+that the charge will land in an orientation that will maximise its destructive potential stop the
+tripwire option is also deprecated since it is more likely that the explosives will be discovered if
+they are attached to such a trigger and moreover it would be difficult to coordinate the charges
+using such a devices top the charges themselves are small but the geometry of the package will focus
+the blast so it is imperative that you install these charges in accordance with the manufacturers
+instructions stop in order to maximise the damage to the towers the engineers recommend that you set
+charges on three of the legs of each tower with charges two and three set to explode in sequence
+after charge one stop set an additional delay of thirty seconds for charge two and one minute twenty
+five seconds for charge three stop as the first leg buckles it will stress the frame so that the
+shockwave of the second charge will distort the supporting members stop with the third explosion the
+frame should buckle resulting in the total destruction of the towers but this sequence will make
+site clearance and reconstruction harder to accomplish stop the delay with charge three also
+increases the likelihood that soldiers will have arrived on site in time to be caught in the third
+blast increasing confusion and loss of morales top if it is possible to climb the tower in advance
+of the demolition to get more detailed images of the aerial and amplifier circuitry then this should
+be attempted however if there is any guard presence then no risks should be taken in this regards
+top we must leave it to you to determine the most effective targets for the operation but the
+demolition must happen simultaneously at all sites for two reasons stop first in order to prevent
+our enemy from disrupting the operation once they realise what is happenings top second we must
+leave no doubt that this was an act of wars top there is a risk that the british government may try
+to reach an accommodation with the fuhrer dividing the world between their dying empire and ours
+just as it is born stop the only way to ensure that we can truly supplant them is to draw them into
+a war they can not win and this project will be the provocation that ensures that this will happens
+top the planning division has determined that january first will be the optimal night for the attack
+as it coincides with a new moon stop they suggest that you split into two teams to attack the
+edmunds t caistor and ca new don sites opening a corridor along the thames for our forthcoming air
+raids stop the support teams should setup lookout posts at the targets in advance of the attack so
+that you can monitor guard movements and make a final assessment of the security stop following the
+operation the sabotage teams should rendezvous together with the support teams at the home of the
+local orts gruppe chief in south maldon stop au boat will standby to pick you all up at three forty
+seven january second with a fallback rendezvous of one thirteen on the thirteenth when the search
+should have died down stop you will need to gain access to a boat capable of carrying you all out to
+meet its top there are very many fishing vessels in this neighbourhood and we recommend stealing one
+after the operations top it might feel less secure that obtaining one in advance however we must do
+everything we can to prevent suspicion in advance of the operations top if this mission succeeds
+then it will be only a matter of days before the war begins and your three comrades in london will
+playa crucial role in coordinating our intelligence efforts behind enemy lines stop we have been
+watching and listening carefully for signs that the operation could have been compromised and as a
+result of those enquiries we have discovered a new top secret agency known only by the acronym boss
+stop we have been unable to infiltrate this group but it is known that the leader is someone with
+the initial hand that they are taking the lead on signals intelligence stop the head of the
+counterintelligence branch uses the codename pearl and we will be making every effort to discover
+her identity stop while the declaration of war and the destruction of the rdf system are the central
+goals of this operation the london triangle will be key to ensuring a flow of high quality
+intelligence to inform our battle plans stop without their communications we will be unable to
+monitor british plans placing german lives at unnecessary risks top if there is any chance that
+members of your group could be captured and interrogated then you should abandon the sabotage
+operation and return to tirpitz ufer stop protecting the identity of the triangle is of far greater
+longterm importance to us stop we can find other ways to provoke the war but we would find it more
+difficult to ensure that we can win it without a network of agents in the capital stop the mission
+will be regarded as a success only if we can guarantee their safety stop to increase the security of
+the london triangle it is crucial that the clock cipher device and the associated code books reach
+our london agents stop the device can not be allowed to fall into enemy hands and this must be the
+top priority stop if you are captured then the codebook containing the keys to the cipher must be
+destroyed stop it is printed on special paper that should easily dissolve but it can also be
+ingested if necessary stop when using the machine take care to erase the cipher alphabet after use
+and to delete the key from the codebook to ensure that no one uses the same key twice stop this will
+also reduce the risk of the keyed cipher falling into enemy hands stop if capture appears imminent
+then use one of the shaped charges to destroy the device preferably burying it together with the
+charge to increase the destructive power and make it harder to reconstruct stop everyone in the
+movement will be praying for your success and your courage and commitment to the fatherland will be
+praised forever stop you are an inspiration to us all stop wishing you luck in the final phase of
+the operations top yours uncle wilhelm
\ No newline at end of file