Done challenge 5
authorNeil Smith <neil.git@njae.me.uk>
Thu, 8 Nov 2018 16:13:29 +0000 (16:13 +0000)
committerNeil Smith <neil.git@njae.me.uk>
Thu, 8 Nov 2018 16:13:29 +0000 (16:13 +0000)
2018/2018-challenge5.ipynb [new file with mode: 0644]
2018/5a.ciphertext [new file with mode: 0644]
2018/5a.plaintext [new file with mode: 0644]
2018/5b.ciphertext [new file with mode: 0644]
2018/5b.plaintext [new file with mode: 0644]

diff --git a/2018/2018-challenge5.ipynb b/2018/2018-challenge5.ipynb
new file mode 100644 (file)
index 0000000..adfa3ad
--- /dev/null
@@ -0,0 +1,614 @@
+{
+ "cells": [
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "import os,sys,inspect\n",
+    "currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))\n",
+    "parentdir = os.path.dirname(currentdir)\n",
+    "sys.path.insert(0,parentdir) "
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 23,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "from cipher.caesar import *\n",
+    "from cipher.affine import *\n",
+    "from cipher.keyword_cipher import *\n",
+    "from cipher.vigenere import *\n",
+    "from support.text_prettify import *\n",
+    "from support.plot_frequency_histogram import *"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 3,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "ca = open('5a.ciphertext').read()\n",
+    "cb = open('5b.ciphertext').read()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 6,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "('ariadne', <KeywordWrapAlphabet.from_largest: 3>, -2373.327599593623)"
+      ]
+     },
+     "execution_count": 6,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "(key_a, wrap_a), score_a = keyword_break_mp(ca)\n",
+    "key_a, wrap_a, score_a"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 8,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "i am still not sure which of the two came up with the idea of the underground archive it will have\n",
+      "appealed to black as away to provide security to his operation but a civil engineering project of\n",
+      "this scale doesnt seem like his sort of things oi think it must have been conceived by charles grey\n",
+      "the first tube line had been opened in and london was full of labourers and engineers with the\n",
+      "skills needed to build the shadow archive deep beneath new scotland yard getting access was not\n",
+      "going to be easy without harrys help but i still didnt have enough to give him the excuse he would\n",
+      "need to get openly involved my reconnaissance had helped me to find the archive but it didnt give me\n",
+      "any obvious way in the duct that had cost me the lidar was far too narrow for me to scale and access\n",
+      "through the frontdoor was too risky so i took a gamble and spent another miserable fortnight\n",
+      "exploring the labyrinth of sewers and tunnel systems around the neighbourhood gps was useless down\n",
+      "there and i could easily have got lost but i marked the tunnels and on occasions used these us trick\n",
+      "of a ball of twine to help me navigate back i moved quietly and kept an eye out for sensors i had no\n",
+      "idea whether the shadow archive was still operational or not but if it was then security would be\n",
+      "tight and i couldnt be sure if they were using infrared or seismometers for intrusion detection so i\n",
+      "layered up with insulation and moved slowly it was horrible i was hot damp and the air smelled of\n",
+      "sewage and mould i was just about to give up when i found a steel door marked with the initial svr i\n",
+      "victoria regina imper atrix it was incongruous in that dark and dank tunnel but more significantly\n",
+      "it carried the trademark tan non the lock john tann was one of the top safe makers in victorian\n",
+      "london and i had cracked one or two of his safes in my other life as a cat burglar this was big and\n",
+      "heavy and very rusty that told me two things no one had used it in a very longtime and no one had\n",
+      "upgraded it in just as long if the room behind it was still in use then someone would have been\n",
+      "maintaining the lock so all my precautions were probably unnecessary but no one had paid for at ann\n",
+      "safe without something important to hide so i decided to tackle the lock and after another eighteen\n",
+      "hours of grim work i was in i had found the shadow archive\n"
+     ]
+    }
+   ],
+   "source": [
+    "print(lcat(tpack(segment(sanitise(keyword_decipher(ca, key_a, wrap_a))))))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 9,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "2328"
+      ]
+     },
+     "execution_count": 9,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "open('5a.plaintext', 'w').write(lcat(tpack(segment(sanitise(keyword_decipher(ca, key_a, wrap_a))))))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 10,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "('disgrace', <KeywordWrapAlphabet.from_largest: 3>, -2302.602730496926)"
+      ]
+     },
+     "execution_count": 10,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "(key_b, wrap_b), score_b = keyword_break_mp(sanitise(cb))\n",
+    "key_b, wrap_b, score_b"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 14,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "st ne vdr slava bnwoduorhtsumtaegnri enel odt no botw of sw on kr no y nec agner ba vdr slava\n",
+      "brftotnaydauqnrco no assam mobs a fgrgulbnobyltnrbrdse fr fda ec yelp node hmo dcr b avg e docks eot\n",
+      "nelp as aft no gne no as ucnobwosotrhtsumyirt edts duos yew leser mo btu or ft rbnrulcnaotnelpegrrn\n",
+      "agnes as ad brft otrs no psr drft rna md rtr got no ost gets f bar dna in at rrm rhl laws\n",
+      "yovnrsdodrpmrrftyllu cr deb gerd tt sum rw gner pod urn drft donna rbn rul cnas taco ft gerd hr ft\n",
+      "nr va irda pm rrf totter dft md rtd rino let nrs rd pye mclr star uierlrftgnefdrftorft no no a savy\n",
+      "de no as nep xr seas sud nana rdotmafnoylrdnebrwk nafta osrietnevgesafott on sae ass\n",
+      "udgrlgadhnuneteftgrb nav nobr hot grrn to nl law rfg ned ewdrftducgaoveotgne no air drft nad rw opc\n",
+      "orb nele hen aetna emot nrrkyldelubatdepsakb dems a hrs ueb duo ots dod rpm rrrdftrftcoruierlrf trie\n",
+      "in rot rl has sop rhye mtas tfi alto ocr ftc or deli rftmodcyeweyelprfttb rd a got g nes dot be\n",
+      "rftrbnrulcnaotydtot no at rd bsagftawgrrbodpotsu wolley emsa ftt nrg udp try g negri e in ry lledo\n",
+      "mr matr me srftterdapmrrftcosr be cow tr ftgl do wrf tots rtedtsnomrgssrdprftg net nr meal dep nag\n",
+      "rt bug no brt up sag darf ty tan utd oppo nest nrs rd pal red sag gner not sgelinrrwtrhtnrmrr dies\n",
+      "agbalhuprftteftk nafta no at brl crd not uhs mae duo tuo he no asuc no bot gerlgluobsaftteftru dts\n",
+      "at agnes bat bet do yirtedtsybalopnorr die otrlhenurdesdrgerlle bata lop duo teft rte nut doc nude\n",
+      "rpp eye mta geod hegner moftesuollebgnekerwi nader ppe k sadr fnr ft no at be nasl\n",
+      "rsnuobrfcarbnrdrcdrt nane as sud nmrg no bott lubac cagr hl law tan rft no at best do pp us rfc ak\n",
+      "docs not do mftawgrbecsarfdrt san amr mad pr ftd oct lubac cags in aftrkemgnenoatnrvdrt nad oct do\n",
+      "ppusotgerlgluobfbafw no at be do crt at rppebalhupegrddatsse ftse rrftconoatsruqrftg nes dodd of\n",
+      "neadeiluhtrlfpmepsr not s gel irm of teter dft dr gnu rhllaweagnaotsrtuod in aged tdu on rft rlp on\n",
+      "at net snob rket gnet be yr ftc agnes ne motto rf trie in rots krr stars ubxrrftsesaftrketlla we as\n",
+      "sudteftksadesardrftr podur cos rad rllrbnefbrftnariedtu ogrsuebsefskdutrftyh no ass rd pp us let udh\n",
+      "stag nee a dei luhn a in as ad pula d per ft\n"
+     ]
+    }
+   ],
+   "source": [
+    "print(lcat(tpack(segment(keyword_decipher(sanitise(cb), key_b, wrap_b)))))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 13,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'dpcbzxnyromwiahsugjklvtfeq'"
+      ]
+     },
+     "execution_count": 13,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "cipher_alphabet, score = simulated_annealing_break(cb, fitness=Pbigrams)\n",
+    "cipher_alphabet"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 15,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'sthikros lakam hge rue oy tsuf ta ichowi hi lerthem et gen sgehv ohebhi pa chi omakros lakam ont etha brauxho pe heassaffem san coculmhem blthomor sin on raipbild heriy ferp omakci rep vsi et hild a sant he chi heasuphem ges et oy tsuf bwotirts rue sbigli si ofemtue ont omhoulpha et hild i cooh a chi sasarm ont et oshedsor ont ohafrotoc et hees tcitsnmaor ha whatoof oy llag sbekho srerodfo ontblluporim ciort tsuf og chi oderuo hrontreh ha omhoulpha sta pe ntciory ont hokaw oradfo ont et tiornt frot rowhel i thosord bif plosta ouwiol ont chin ronte ont heheasak briheashidjo siassur ha haor et fan he blor him og vhant a es owithikci san et teh sa iassur colcaryhu hi tint comhakhem oy et cooh teh llag on chi rig rontrup caeki et chi heawor ont ha roged pe omhiliy i haithaif et hoov blrilumatrid sa vmrifsayosuim rue et srerodfo oornt ont pe ouwiol ont owiwho et olyassed oy bif ta stnwalteep ont pe orilw ont ferp bigi bild ont tmorac et chi sretmi ont omhoulpha et brt et heatormsac ntag coomerd et su gelli bif sant thocurd tob chi cowiwho blliref ofat ofis ont ti oradfo ont pe somip egt ont clreg ont et sotirtshefoc ssord ont chi thofialrid ha cotmuchem otudsac raont btahutredde hi sthosord aloirsac chi ohetscilw hoogtoy thofoorwisac malyud ont tint vhant a heatmolpor he tuy sfai rue tueyi heasuphem et ciol cluem sant tint ourt sa ta chi smatmit re bwotirts bmaled he oorwi et olyihu ori srociol limataled rue tint otihutrephu rioddi bif ta cieryi chi ofen ti suellim chi viog wharioddi vsar on hont heatmiha sloshuem on pa omhoroprotha hiassur hfochem et tlumappac oy llag ta hont heatmi streddus on pa vrep shetref ntag comip sa on rotsahaf ofard ont rep tlumappac swhant ovif chi heathokrotha rep treddus et ciol cluem nmang heatmi rep otatoddi malyud i corrats sin tsio ont pe heatsoux ont chi srerren hiariwluy tolndfid sohetscilw ofen titiornt rochu oy llag iacha et sotuer whacirt rue hont oldehathitshem ovit chi tmi bont pa chi shifette ont owiwho et svoos ta osumjo ont si sant ovit llag iassur tint vsar i sa oront oderuo pe soarollomhinm ont ha owirtue cosuim sin svrut ont by heassorddus litury sta chi iariwluy ha whasardu lardi ont\\n'"
+      ]
+     },
+     "execution_count": 15,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "# cipher_alphabet = 'cpearstubomykvliqghjdxnwzf'\n",
+    "cipher_translation = ''.maketrans(cipher_alphabet, string.ascii_lowercase)\n",
+    "plaintext = cb.lower().translate(cipher_translation)\n",
+    "plaintext"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 19,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'dwwwwtdvwwgvzwvgwww'"
+      ]
+     },
+     "execution_count": 19,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "key_b, score_b = vigenere_frequency_break(cb)\n",
+    "key_b"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 20,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'GOCVQNEO AXREM SRD DPD LL PNPR LH LGCLQV CV TEKOSEJ EE RDX NRDFS LCTUZV MH GVV LMKJLLN BEQIC LEH DOCK UKHFKZL MD CWHNNHEUEM DIB HBGPAFCDM WTPCLCMH OLE LX KHVZMWAF DAKWY BDDW LMKJHV AET ADV DH CVAI I NXFL DT GCO CDHQIXCDC ODO DO EI ONSU TXBPSKPD KPW NTVUTW NL IBECOPD LEO OFDLPQXZH TO COAF V ZMLC I GDL NHGHKM OXP DE INDTFNLD LEO EDHBAMLLH DO VDDN RZWONUNELL CH QCHOLOU LI BXHS NTDJCL NNWLLFRM LFETAAIWLKVP HVLAP OOFB LK GCV EGDKFM CLBEOKWC CH ENCLFBTCI NOH WD ERZWLKY IEP CLQAX LKKYCL BFL EE OVEKEO EDMO AMUCEQ V HCLNLNY TVR TAMDOH EPXVLD MEO HZVF KLEHD LER DDCTIKHR TKVVDHNCYYTL DWENOFK CA CHLN EO RIB DT TAEK CVP MR PDEEP H DG LXVRVWQGL KHF DO HDC NK WHNDQH HBAGHDICP FO OVUP GMCCHQVDM LL EO WMIC EDC TAHR OX GCL HVS KLEHKPW JAEQV EL HSV CWHXLK EFO SI KMHDF PD LMFOBVI W CILOCHOB DO VMLZ UXKWQPMHHKVF QA ZMAWYNIYLNPOM KPG EO DLAKMVBL ELKEO EFO ME LQNVLA LEO OQWXCB AO BAIHGNDF OB TVR LH DOEXAAODDZ MEO XA MAVAX LEO EWLW JWOV JVAF LEO RFMKHW AO WCV GKDOMY MEO MJCMFAWCA DO WDP DE ZDIELKMGHG ERAS GBMJDLV DO NP RGTBV JWY OXEO HCLGPNY OLJ DCW GLXOXCL WTBVKTC LCXO LUVN LHH OV MHHGRL LXO WD GMMVM ARP LEO GAKDU MEO EL OBOVKHNCDBOZ NNBLC MUO GVV OCOUWHAAWC DX GLHMPGCGF LOFGKHH KHLXO TOKVQOKTGCD SV NHCLNLNY HABWHNIW GCO LCDRGHVAN ZLMHOLI OCLBOELXVDID NXAIPY LEO HWEO AZHFE H VDHOMOTXLK DA PFI NUHV KSW OPTJS DTHNPPCDM GH GVBB GBFDM GHEO ROFO BQHO DH OA GCV GNHOCWL LT TXEOVKOQ UMHQEC DT LLDXV DR MAILDM MAV NDLGVLD BVMXPEAEV KPW OVER MOVSQLKEMCP DVLFFY UVB PE HLDKIO GCV ECDE PS OFDAAOM GCY AVLH UCIAVLFYV ZNKD LE DIEP CDHHMVCH GBLNSQAM BE WA LMCODMWKBPZH SVHNGPK CEEHCDC AO EAPMAWWHG EJ AQIO PX CLXO CDKHNV DPHDGVPN EE WH SLDW OZDPADB XOHR JENVW OE MU KLHNHCHE MBHAG LFE KDP OAPPAXWHW KXDXEO EZVB JVW CTILCMGKLOVH KDZ PKDVGMN TO GOLA GDIEM UNEES CDHHMV KGP LOXPIFGL MHTIPF Y HLKAILN DVE HNVL OXP WT ZDIENLPC LEO ZDV DLAKLTE COHKVXDIJ OBBBFCLF NECDONJOBX BCAE EVOVEKEO NEHCP MF BQHR OHGCH WP NBPMDL XCHZVKO NIE CBFL MQFDCAOCVOQVEM BASO WCV HMV TOXP WX DCW NCVUDOOD EFO BYSXDB DO NZLLQ PH BOMMTB LEH NV QAFO BASO QAHR VHNNSD OVUP ZOXK V NH LNEFO BGAKQB WD NLHKOTBLMSWBM BEO VH LXYDPPD HINQLM NOE NZNIP LUP TJ CDHGNLKFIIO ALPMKJ NOH GCV YALVXQQF DX XCANHKFS BHKVW LFE\\n'"
+      ]
+     },
+     "execution_count": 20,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "vigenere_decipher(cb, key_b)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 24,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "/usr/local/lib/python3.6/dist-packages/matplotlib/figure.py:459: UserWarning: matplotlib is currently using a non-GUI backend, so cannot show the figure\n",
+      "  \"matplotlib is currently using a non-GUI backend, \"\n"
+     ]
+    },
+    {
+     "data": {
+      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAbAAAAEmCAYAAAADccV0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvhp/UCwAAFUpJREFUeJzt3X+wZGV95/H3RyCJggkgV0KQ8YqZuKvJOsiVxTWkiGiCoEF3DYGogDE7soFSd2O2QDer5caqSdRYm9oNZohT4IYQMIiwglFqdE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mO6gJ6S2+9hV6Y7QirgbckeT5Akn2TvHCI/kuSvKrb/m3gqgH7PUTvVM9i/AXwh8B5wB8P0zHJzwGPVNVfAR8FXjFE98U+153ly8BvJnke9L62A/b7GvA+4Mpu+1R6s4tBAvtn6J09eCTJv6B3SnJH+Drwxu5vo3sBbxi0Y5JD6T3ft3VnT4ZxMXA0vVOYXxyi35X0XmeeneS5wBuHHHdUP6T32nZSkt/ewWOPhTOweVTVuiTn0Dv3D/CX3em9HTH2jd03891VtXkHjXlTkv8CfCm9q5h+BJwG3DngQ9wKnJZkFb3f5M4acNz7ugtcNgBfqKo/GKRfkpOAH1XVX3cXm3wjyWuq6ssD1vtLwEeTPEHvuf6HAfvBIp/rztJ9P30E+GqSx+n9veOUAbp+DfgA8M2q+kGSf2LwX+L+Djg1yc30Pl+LOb0FQ85uq+qaJJfSmzHeQ+9U8aCnh08H9gW+kgR6C9X+7oDj/rC76OP/VdXjQ9S7LskFwHXAvfTWkN2huq/tG4ArkjxcVU2tWetKHBpJklng81U18FWA0kK6GeO6qhrmTABJ9qqqh7urQ68EllfVuokU+eMxnwWsA36zqm6b5FjalqcQJe1SulO836R3lemwVnYXIq0DLtoB4fVSelcPrja8djxnYJKkJjkDkyQ1yQCTJDXJAJMkNckAkyQ1yQCTJDXJAJMkNen/A9pBMTeu+d9jAAAAAElFTkSuQmCC\n",
+      "text/plain": [
+       "<Figure size 432x288 with 1 Axes>"
+      ]
+     },
+     "metadata": {},
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "fc = collections.Counter(sanitise(cb))\n",
+    "plot_frequency_histogram(fc, sort_key=fc.get)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 54,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'JHGMRYKJ IDMDW ZNY ZLG EH XLJK DK RTHYCR RY IZYKGZW KZ AZN VYZNJ RYPZYH DS RYC JHGMDIH IDMDW KAH DYKZ HYFLDGP ZS IZXXDJJDZY ADJ IZYIWLCHC GHIHYKWP ARJ AH BWRPSRDG ERGZY SGZX RCMDIH SZG RJV KZ BWRY D KADJ ZY RYC IZYSLJDZY JZN KZ EH XLJK JKGRKHTP ZLG RWNRPJ RJ ZLKIZXH KAH DYSWLHYIH KZ BWRY R YHHC D RYC IGDJDJ KAH KZ GHJBZYJH KAH CHKHGXDYH KZ JZZY GHDIAJKRCK DY XHHKDYT EH NDWW HYMZPJ HXBHGZGJ IRGHSLWWPKAH KGHRC XLJK NH RYC HLGZBH YZGKAHGY DY DYSWLHYIH DKJ ZS EGHRCKA KAH TDMHY HXBDGH KAH KZ KAGHRK KHGX WZYTHG R BGHJHYK XRP DKJHWS WHRTLH KAH ARYC ZKAHG KAH MDJDZYZY HOBRYJDZYRGP GLJJDRJ DY GHDY KZ ADX ZY GHWP IRY NH KADYV D JZ RCMRYKRTH ADJ KZ YZK DJ GLJJDR LYEGDCWHC RY KARK IZYMDYIHC EH KZ YHHC YZK NDWW AH RYC NRG SLGKAHG RMZDC KZ RYC GHTDZY KAH DY BZNHG ZS ERWRYIH R XRDYKRDY KZ VHHY BRGKDILWRGWP DJ IRLJHEDJXRGIV ZLG KZ HXBHGZGJ KAGHH KAH ZS WHRTLH KAH HYTRTH KZ BZJJDEWH EH XRP DK SZZKWDTAKJ KAH ZS TWRGH KAH SGZX RNRP BWRP KAH CDGHIK KZ RYC RIKZGJ KAH DYSWLHYIH KZ KGP KZ CDJIGHKDZY NDKA BGZIHHC KZ LJ RWWZN XRP KADJ BGLCHYK PHK RYC HYTRTHC XZGRWWP KDXH JRXH KAH RK HXBDGH KAH ZS SRIHJ KNZ KAH NZGWC KAH KZ CHXZYJKGRKHJ BGHJJ KAH RYC BRGWDRXHYK DY IZYCLIKHC CDJBLKH KAHDG ZBBZGKLYDKP RY BGHJHYKJ CDJGRHWD RYC TWRCJKZYH EHKNHHY CDJRTGHHXHYK BLEWDI KAH KARK KADYV D GHSWHIKDZY ZY ELK RDXJ ZLG REZLK IZYSLJDZY KZ WHRC IZLWC KADJ KARK KGLH DJ DK RYC KRIKDIJ ZG JKGRKHTP BZWDIP ZY RTGHH KZ LYREWH RGH WHRCHGJ BZWDKDIRW ZLG KARK LYSZGKLYRKH RBBHRG XRP DK REGZRC RYC AZXH RK IRWWZLJ RYC NHRV RBBHRGDYT GDJV AH KAHY DYRIKDZY IZLYJHWJ AH DS DYKHGSHGHYIH GLJJDRY IZYCHXY KZ CDSSDILWK EH NDWW DK KAHY RIKDZY JLBBZGKJ AH DS SZGV XZGKZYJ NDKA SRIHC DJ AH XDYDJKHG BGDXH KAH SZG CDSSDILWK KADYTJ XRVH RYC DYKHGMHYKDZY SZG JLBBZGK KZ WHRC IZLWC NADIA RIKDZY SZG RBBHKDKH BLEWDI R JKDGGHC ARJ HRJK KAH ZS FLHJKDZY KAH RYC AZGGZGJ ELWTRGDRY BRXBAWHK TWRCJKZYHJ AZXH KAGHRKRK LYCHG EH NDWW DYCDR KZ GZLKHJ KGRCDYT ZLG KAHY IZYJKRYKDYZBWH KRVH RYC RIK KAHP DS RYC ZKKZXRYJ KAH HYTRTH KZ JHHVJ DK HOILJH KAH RJ KADJ KRVH NDWW GLJJDR KARK GDJV R DJ KAHGH HLGZBH ZS IARYIHWWHGDHJ KAH DY ZLKGRTH IRLJHC ARJ KLGVJ KAH EP JLBBGHJJDZY EGLKRW DKJ RYC ELWTRGDR DY LBGDJDYT RBGDW KAH'"
+      ]
+     },
+     "execution_count": 54,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "cb_rev_word = wcat(cat(reversed(w)) for w in cb.split())\n",
+    "cb_rev_word"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 56,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "True"
+      ]
+     },
+     "execution_count": 56,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "len(sanitise(cb)) == len(sanitise(cb_rev_word))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 35,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "('disgrace', <KeywordWrapAlphabet.from_largest: 3>, -2302.6027304969257)"
+      ]
+     },
+     "execution_count": 35,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "(key_b, wrap_b), score_b = keyword_break_mp(sanitise(cb_rev_word))\n",
+    "key_b, wrap_b, score_b"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 38,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'srdvents baval own oud hr must at eirnge en bontdol to fow knows enyonr ac eng srdvabr baval tfr anto rnquady oc bommassaon fas bonblugrg drbrntly fes fr pleycead hedon cdom egvabr cod esk to plen a tfas on eng boncusaon sow to hr must stdetriy oud elweys es outbomr tfr anclurnbr to plen e nrrg a eng bdasas tfr to drsponsr tfr grtrdmanr to soon drabfstegt an mrrtani hr wall rnvoys rmprdods bedrcullytfr tdreg must wr eng rudopr nodtfrdn an anclurnbr ats oc hdregtf tfr iavrn rmpadr tfr to tfdret trdm lonird e pdrsrnt mey atsrlc lreiur tfr feng otfrd tfr vasaonon rxpensaonedy dussaes an dran to fam on drly ben wr tfank a so egventeir fas to not as dussae unhdaglrg en tfet bonvanbrg hr to nrrg not wall fr eng wed cudtfrd evoag to eng driaon tfr an powrd oc helenbr e meantean to krrn pedtabuledly as beusrhasmedbk oud to rmprdods tfdrr tfr oc lreiur tfr rnieir to possahlr hr mey at cootlaifts tfr oc iledr tfr cdom ewey pley tfr gadrbt to eng ebtods tfr anclurnbr to tdy to gasbdrtaon watf pdobrrg to us ellow mey tfas pdugrnt yrt eng rnieirg modelly tamr semr tfr et rmpadr tfr oc cebrs two tfr wodlg tfr to grmonstdetrs pdrss tfr eng pedlaemrnt an bongubtrg gasputr tfrad oppodtunaty en pdrsrnts gasderla eng ilegstonr hrtwrrn gaseidrrmrnt puhlab tfr tfet tfank a drclrbtaon on hut eams oud ehout boncusaon to lreg boulg tfas tfet tdur as at eng tebtabs od stdetriy polaby on eidrr to unehlr edr lregrds polatabel oud tfet uncodtunetr eppred mey at ehdoeg eng fomr et bellous eng wrek eppredani dask fr tfrn anebtaon bounsrls fr ac antrdcrdrnbr dussaen bongrmn to gaccabult hr wall at tfrn ebtaon suppodts fr ac codk modtons watf cebrg as fr manastrd pdamr tfr cod gaccabult tfanis mekr eng antrdvrntaon cod suppodt to lreg boulg wfabf ebtaon cod epprtatr puhlab e staddrg fes rest tfr oc qurstaon tfr eng foddods huliedaen pempflrt ilegstonrs fomr tfdretet ungrd hr wall angae to doutrs tdegani oud tfrn bonstentanoplr tekr eng ebt tfry ac eng ottomens tfr rnieir to srrks at rxbusr tfr es tfas tekr wall dussae tfet dask e as tfrdr rudopr oc bfenbrllrdars tfr an outdeir beusrg fes tudks tfr hy suppdrssaon hdutel ats eng huliedae an updasani epdal tfr'"
+      ]
+     },
+     "execution_count": 38,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "keyword_decipher(cb_rev_word, key_b, wrap_b)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 57,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'reichstaduvwxyzbfgjklmnopq'"
+      ]
+     },
+     "execution_count": 57,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "cipher_alphabet, score = simulated_annealing_break(cb_rev_word, fitness=Ptrigrams)\n",
+    "cipher_alphabet"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 60,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'reichstaduvwxyzbfgjklmnopq'"
+      ]
+     },
+     "execution_count": 60,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "cipher_alphabet, score = simulated_annealing_break(cat(list(reversed(cb))), fitness=Ptrigrams)\n",
+    "cipher_alphabet"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 61,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'reichstaduvwxyzbfgjklmnopq'"
+      ]
+     },
+     "execution_count": 61,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "keyword_cipher_alphabet_of('reichstadt', KeywordWrapAlphabet.from_largest)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 48,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "the april uprising in bulgaria and its brutal suppression by the turks has caused outrage in the\n",
+      "chancelleries of europe there is a risk that russia will take this as the excuse it seeks to engage\n",
+      "the ottomans and if they act and take constantinople then our trading routes to india will be under\n",
+      "threatat home gladstones pamphlet bulgarian horrors and the question of the east has stirred a\n",
+      "public appetite for action which could lead to support for intervention and make things difficult\n",
+      "for the prime minister he is faced with mortons fork if he supports action then it will be difficult\n",
+      "to condemn russian interference if he counsels inaction then he risk appearing weak and callous at\n",
+      "home and abroad it may appear unfortunate that our political leaders are unable to agree on policy\n",
+      "strategy or tactics and it is true that this could lead to confusion about our aims but on\n",
+      "reflection i think that the public disagreement between gladstone and disraeli presents an\n",
+      "opportunity their dispute conducted in parliament and the press demonstrates to the world the two\n",
+      "faces of the empire at the same time morally engaged and yet prudent this may allow us to proceed\n",
+      "with discretion to try to influence the actors and to direct the play away from the glare of the\n",
+      "footlights it may be possible to engage the league of the three emperors to our causebismarck is\n",
+      "particularly keen to maintain a balance of power in the region and to avoid further war and he will\n",
+      "not need to be convinced that an unbridled russia is not to his advantage so i think we can rely on\n",
+      "him to rein in russias expansionary visionon the other hand the league itself may present a longer\n",
+      "term threat to the empire given the breadth of its influence in northern europe and we must tread\n",
+      "carefullythe emperors envoys will be meeting in reichstadt soon to determine the response to the\n",
+      "crisis and i need a plan to influence the outcome as always our strategy must be to sow confusion\n",
+      "and on this i plan to ask for advice from baron playfair he has recently concluded his commission of\n",
+      "enquiry into the civil service and if anyone knows how to control an agenda it must be our own civil\n",
+      "servants\n"
+     ]
+    }
+   ],
+   "source": [
+    "# cipher_alphabet = 'reichstadqvwxyzbfgjklmnopu'\n",
+    "cipher_translation = ''.maketrans(cipher_alphabet, string.ascii_lowercase)\n",
+    "plaintext = cb_rev_word.lower().translate(cipher_translation)\n",
+    "plaintext_words = plaintext.split()\n",
+    "print(lcat(tpack(list(reversed(plaintext_words)))))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 48,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "the april uprising in bulgaria and its brutal suppression by the turks has caused outrage in the\n",
+      "chancelleries of europe there is a risk that russia will take this as the excuse it seeks to engage\n",
+      "the ottomans and if they act and take constantinople then our trading routes to india will be under\n",
+      "threatat home gladstones pamphlet bulgarian horrors and the question of the east has stirred a\n",
+      "public appetite for action which could lead to support for intervention and make things difficult\n",
+      "for the prime minister he is faced with mortons fork if he supports action then it will be difficult\n",
+      "to condemn russian interference if he counsels inaction then he risk appearing weak and callous at\n",
+      "home and abroad it may appear unfortunate that our political leaders are unable to agree on policy\n",
+      "strategy or tactics and it is true that this could lead to confusion about our aims but on\n",
+      "reflection i think that the public disagreement between gladstone and disraeli presents an\n",
+      "opportunity their dispute conducted in parliament and the press demonstrates to the world the two\n",
+      "faces of the empire at the same time morally engaged and yet prudent this may allow us to proceed\n",
+      "with discretion to try to influence the actors and to direct the play away from the glare of the\n",
+      "footlights it may be possible to engage the league of the three emperors to our causebismarck is\n",
+      "particularly keen to maintain a balance of power in the region and to avoid further war and he will\n",
+      "not need to be convinced that an unbridled russia is not to his advantage so i think we can rely on\n",
+      "him to rein in russias expansionary visionon the other hand the league itself may present a longer\n",
+      "term threat to the empire given the breadth of its influence in northern europe and we must tread\n",
+      "carefullythe emperors envoys will be meeting in reichstadt soon to determine the response to the\n",
+      "crisis and i need a plan to influence the outcome as always our strategy must be to sow confusion\n",
+      "and on this i plan to ask for advice from baron playfair he has recently concluded his commission of\n",
+      "enquiry into the civil service and if anyone knows how to control an agenda it must be our own civil\n",
+      "servants\n"
+     ]
+    }
+   ],
+   "source": [
+    "# cipher_alphabet = 'reichstadqvwxyzbfgjklmnopu'\n",
+    "cipher_translation = ''.maketrans(cipher_alphabet, string.ascii_lowercase)\n",
+    "plaintext = cb_rev_word.lower().translate(cipher_translation)\n",
+    "plaintext_words = plaintext.split()\n",
+    "print(lcat(tpack(list(reversed(plaintext_words)))))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 64,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "the april uprising in bulgaria and its brutal suppression by the turks has caused outrage in the\n",
+      "chancelleries of europe there is a risk that russia will take this as the excuse it seeks to engage\n",
+      "the ottomans and if they act and take constantinople then our trading routes to india will be under\n",
+      "threatat home gladstones pamphlet bulgarian horrors and the question of the east has stirred a\n",
+      "public appetite for action which could lead to support for intervention and make things difficult\n",
+      "for the prime minister he is faced with mortons fork if he supports action then it will be difficult\n",
+      "to condemn russian interference if he counsels inaction then he risk appearing weak and callous at\n",
+      "home and abroad it may appear unfortunate that our political leaders are unable to agree on policy\n",
+      "strategy or tactics and it is true that this could lead to confusion about our aims but on\n",
+      "reflection i think that the public disagreement between gladstone and disraeli presents an\n",
+      "opportunity their dispute conducted in parliament and the press demonstrates to the world the two\n",
+      "faces of the empire at the same time morally engaged and yet prudent this may allow us to proceed\n",
+      "with discretion to try to influence the actors and to direct the play away from the glare of the\n",
+      "footlights it may be possible to engage the league of the three emperors to our causebismarck is\n",
+      "particularly keen to maintain a balance of power in the region and to avoid further war and he will\n",
+      "not need to be convinced that an unbridled russia is not to his advantage so i think we can rely on\n",
+      "him to rein in russias expansionary visionon the other hand the league itself may present a longer\n",
+      "term threat to the empire given the breadth of its influence in northern europe and we must tread\n",
+      "carefullythe emperors envoys will be meeting in reichstadt soon to determine the response to the\n",
+      "crisis and i need a plan to influence the outcome as always our strategy must be to sow confusion\n",
+      "and on this i plan to ask for advice from baron playfair he has recently concluded his commission of\n",
+      "enquiry into the civil service and if anyone knows how to control an agenda it must be our own civil\n",
+      "servants\n"
+     ]
+    }
+   ],
+   "source": [
+    "cb_rev = cat(list(reversed(cb))).strip()\n",
+    "kpt = keyword_decipher(cb_rev, 'reichstadt', KeywordWrapAlphabet.from_largest)\n",
+    "print(lcat(tpack(kpt.split())))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 65,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "2163"
+      ]
+     },
+     "execution_count": 65,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "open('5b.plaintext', 'w').write(lcat(tpack(kpt.split())))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  }
+ ],
+ "metadata": {
+  "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.6.6"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/2018/5a.ciphertext b/2018/5a.ciphertext
new file mode 100644 (file)
index 0000000..a8bb657
--- /dev/null
@@ -0,0 +1 @@
+UAYHJ UXXZB JHKGN MTUIT BEJTN JMBIA YNKCM UJTJT NUDNA BEJTN KZDNG SGBKZ DAGIT ULNUJ MUXXT ALNAC CNAXN DJBRX AIWAH AMAPJ BCGBL UDNHN IKGUJ PJBTU HBCNG AJUBZ RKJAI ULUXN ZSUZN NGUZS CGBVN IJBEJ TUHHI AXNDB NHZJH NNYXU WNTUH HBGJB EJTUZ SHBUJ TUZWU JYKHJ TALNR NNZIB ZINUL NDRPI TAGXN HSGNP JTNEU GHJJK RNXUZ NTADR NNZBC NZNDU ZAZDX BZDBZ MAHEK XXBEX ARBKG NGHAZ DNZSU ZNNGH MUJTJ TNHWU XXHZN NDNDJ BRKUX DJTNH TADBM AGITU LNDNN CRNZN AJTZN MHIBJ XAZDP AGDSN JJUZS AIINH HMAHZ BJSBU ZSJBR NNAHP MUJTB KJTAG GPHTN XCRKJ UHJUX XDUDZ JTALN NZBKS TJBSU LNTUY JTNNO IKHNT NMBKX DZNND JBSNJ BCNZX PUZLB XLNDY PGNIB ZZAUH HAZIN TADTN XCNDY NJBEU ZDJTN AGITU LNRKJ UJDUD ZJSUL NYNAZ PBRLU BKHMA PUZJT NDKIJ JTAJT ADIBH JYNJT NXUDA GMAHE AGJBB ZAGGB MEBGY NJBHI AXNAZ DAIIN HHJTG BKSTJ TNEGB ZJDBB GMAHJ BBGUH WPHBU JBBWA SAYRX NAZDH CNZJA ZBJTN GYUHN GARXN EBGJZ USTJN OCXBG UZSJT NXARP GUZJT BEHNM NGHAZ DJKZZ NXHPH JNYHA GBKZD JTNZN USTRB KGTBB DSCHM AHKHN XNHHD BMZJT NGNAZ DUIBK XDNAH UXPTA LNSBJ XBHJR KJUYA GWNDJ TNJKZ ZNXHA ZDBZB IIAHU BZHKH NDJTN HNKHJ GUIWB EARAX XBEJM UZNJB TNXCY NZALU SAJNR AIWUY BLNDF KUNJX PAZDW NCJAZ NPNBK JEBGH NZHBG HUTAD ZBUDN AMTNJ TNGJT NHTAD BMAGI TULNM AHHJU XXBCN GAJUB ZAXBG ZBJRK JUEUJ MAHJT NZHNI KGUJP MBKXD RNJUS TJAZD UIBKX DZJRN HKGNU EJTNP MNGNK HUZSU ZEGAG NDBGH NUHYB YNJNG HEBGU ZJGKH UBZDN JNIJU BZHBU XAPNG NDKCM UJTUZ HKXAJ UBZAZ DYBLN DHXBM XPUJM AHTBG GURXN UMAHT BJDAY CAZDJ TNAUG HYNXX NDBEH NMASN AZDYB KXDUM AHVKH JARBK JJBSU LNKCM TNZUE BKZDA HJNNX DBBGY AGWND MUJTJ TNUZU JUAXH LGULU IJBGU AGNSU ZAUYC NGAJG UOUJM AHUZI BZSGK BKHUZ JTAJD AGWAZ DDAZW JKZZN XRKJY BGNHU SZUEU IAZJX PUJIA GGUND JTNJG ADNYA GWJAZ ZBZJT NXBIW VBTZJ AZZMA HBZNB EJTNJ BCHAE NYAWN GHUZL UIJBG UAZXB ZDBZA ZDUTA DIGAI WNDBZ NBGJM BBETU HHAEN HUZYP BJTNG XUENA HAIAJ RKGSX AGJTU HMAHR USAZD TNALP AZDLN GPGKH JPJTA JJBXD YNJMB JTUZS HZBBZ NTADK HNDUJ UZALN GPXBZ SJUYN AZDZB BZNTA DKCSG ADNDU JUZVK HJAHX BZSUE JTNGB BYRNT UZDUJ MAHHJ UXXUZ KHNJT NZHBY NBZNM BKXDT ALNRN NZYAU ZJAUZ UZSJT NXBIW HBAXX YPCGN IAKJU BZHMN GNCGB RARXP KZZNI NHHAG PRKJZ BBZNT ADCAU DEBGA JAZZH AENMU JTBKJ HBYNJ TUZSU YCBGJ AZJJB TUDNH BUDNI UDNDJ BJAIW XNJTN XBIWA ZDAEJ NGAZB JTNGN USTJN NZTBK GHBES GUYMB GWUMA HUZUT ADEBK ZDJTN HTADB MAGIT ULN
diff --git a/2018/5a.plaintext b/2018/5a.plaintext
new file mode 100644 (file)
index 0000000..86bfbfa
--- /dev/null
@@ -0,0 +1,24 @@
+i am still not sure which of the two came up with the idea of the underground archive it will have
+appealed to black as away to provide security to his operation but a civil engineering project of
+this scale doesnt seem like his sort of things oi think it must have been conceived by charles grey
+the first tube line had been opened in and london was full of labourers and engineers with the
+skills needed to build the shadow archive deep beneath new scotland yard getting access was not
+going to be easy without harrys help but i still didnt have enough to give him the excuse he would
+need to get openly involved my reconnaissance had helped me to find the archive but it didnt give me
+any obvious way in the duct that had cost me the lidar was far too narrow for me to scale and access
+through the frontdoor was too risky so i took a gamble and spent another miserable fortnight
+exploring the labyrinth of sewers and tunnel systems around the neighbourhood gps was useless down
+there and i could easily have got lost but i marked the tunnels and on occasions used these us trick
+of a ball of twine to help me navigate back i moved quietly and kept an eye out for sensors i had no
+idea whether the shadow archive was still operational or not but if it was then security would be
+tight and i couldnt be sure if they were using infrared or seismometers for intrusion detection so i
+layered up with insulation and moved slowly it was horrible i was hot damp and the air smelled of
+sewage and mould i was just about to give up when i found a steel door marked with the initial svr i
+victoria regina imper atrix it was incongruous in that dark and dank tunnel but more significantly
+it carried the trademark tan non the lock john tann was one of the top safe makers in victorian
+london and i had cracked one or two of his safes in my other life as a cat burglar this was big and
+heavy and very rusty that told me two things no one had used it in a very longtime and no one had
+upgraded it in just as long if the room behind it was still in use then someone would have been
+maintaining the lock so all my precautions were probably unnecessary but no one had paid for at ann
+safe without something important to hide so i decided to tackle the lock and after another eighteen
+hours of grim work i was in i had found the shadow archive
\ No newline at end of file
diff --git a/2018/5b.ciphertext b/2018/5b.ciphertext
new file mode 100644 (file)
index 0000000..d3ffb27
--- /dev/null
@@ -0,0 +1 @@
+JKYRMGHJ WDMDI YNZ GLZ HE KJLX KD RCYHTR YR WZGKYZI ZK NZA JNZYV HYZPYR SD CYR HIDMGHJ WDMDI HAK ZKYD PGDLFYH SZ YZDJJDXXZI JDA CHCLWIYZI PWKYHIHG JRA HA GDRSPRWB YZGRE XZGS HIDMCR GZS VJR ZK YRWB D JDAK YZ CYR YZDJLSYZI NZJ ZK HE KJLX PTHKRGKJ GLZ JPRNWR JR HXZIKLZ HAK HIYHLWSYD ZK YRWB R CHHY D CYR JDJDGI HAK ZK HJYZBJHG HAK HYDXGHKHC ZK YZZJ KCRKJAIDHG YD TYDKHHX HE WWDN JPZMYH JGZGHBXH HAKPWWLSHGRI CRHGK KJLX HN CYR HBZGLH YGHAKGZY YD HIYHLWSYD JKD SZ AKCRHGE HAK YHMDT HGDBXH HAK ZK KRHGAK XGHK GHTYZW R KYHJHGB PRX SWHJKD HLTRHW HAK CYRA GHAKZ HAK YZYZDJDM PGRYZDJYRBOH JRDJJLG YD YDHG ZK XDA YZ PWHG YRI HN VYDAK D ZJ HTRKYRMCR JDA ZK KZY JD RDJJLG CHWCDGEYL YR KRAK CHIYDMYZI HE ZK CHHY KZY WWDN HA CYR GRN GHAKGLS CDZMR ZK CYR YZDTHG HAK YD GHNZB SZ HIYRWRE R YDRKYDRX ZK YHHV PWGRWLIDKGRB JD VIGRXJDEHJLRI GLZ ZK JGZGHBXH HHGAK HAK SZ HLTRHW HAK HTRTYH ZK HWEDJJZB HE PRX KD JKATDWKZZS HAK SZ HGRWT HAK XZGS PRNR PRWB HAK KIHGDC ZK CYR JGZKIR HAK HIYHLWSYD ZK PGK ZK YZDKHGIJDC AKDN CHHIZGB ZK JL NZWWR PRX JDAK KYHCLGB KHP CYR CHTRTYH PWWRGZX HXDK HXRJ HAK KR HGDBXH HAK SZ JHIRS ZNK HAK CWGZN HAK ZK JHKRGKJYZXHC JJHGB HAK CYR KYHXRDWGRB YD CHKILCYZI HKLBJDC GDHAK PKDYLKGZBBZ YR JKYHJHGB DWHRGJDC CYR HYZKJCRWT YHHNKHE KYHXHHGTRJDC IDWELB HAK KRAK VYDAK D YZDKIHWSHG YZ KLE JXDR GLZ KLZER YZDJLSYZI ZK CRHW CWLZI JDAK KRAK HLGK JD KD CYR JIDKIRK GZ PTHKRGKJ PIDWZB YZ HHGTR ZK HWERYL HGR JGHCRHW WRIDKDWZB GLZ KRAK HKRYLKGZSYL GRHBBR PRX KD CRZGER CYR HXZA KR JLZWWRI CYR VRHN TYDGRHBBR VJDG HA YHAK YZDKIRYD JWHJYLZI HA SD HIYHGHSGHKYD YRDJJLG YXHCYZI ZK KWLIDSSDC HE WWDN KD YHAK YZDKIR JKGZBBLJ HA SD VGZS JYZKGZX AKDN CHIRS JD HA GHKJDYDX HXDGB HAK GZS KWLIDSSDC JTYDAK HVRX CYR YZDKYHMGHKYD GZS KGZBBLJ ZK CRHW CWLZI AIDAN YZDKIR GZS HKDKHBBR IDWELB R CHGGDKJ JRA KJRH HAK SZ YZDKJHLF HAK CYR JGZGGZA YRDGRTWLE KHWABXRB JHYZKJCRWT HXZA KRKRHGAK GHCYL HE WWDN RDCYD ZK JHKLZG TYDCRGK GLZ YHAK HWBZYDKYRKJYZI HVRK CYR KIR PHAK SD CYR JYRXZKKZ HAK HTRTYH ZK JVHHJ KD HJLIOH HAK JR JDAK HVRK WWDN RDJJLG KRAK VJDG R JD HGHAK HBZGLH SZ JHDGHWWHIYRAI HAK YD HTRGKLZ CHJLRI JRA JVGLK HAK PE YZDJJHGBBLJ WRKLGE JKD CYR RDGRTWLE YD TYDJDGBL WDGBR HAK
diff --git a/2018/5b.plaintext b/2018/5b.plaintext
new file mode 100644 (file)
index 0000000..8838f59
--- /dev/null
@@ -0,0 +1,23 @@
+the april uprising in bulgaria and its brutal suppression by the turks has caused outrage in the
+chancelleries of europe there is a risk that russia will take this as the excuse it seeks to engage
+the ottomans and if they act and take constantinople then our trading routes to india will be under
+threatat home gladstones pamphlet bulgarian horrors and the question of the east has stirred a
+public appetite for action which could lead to support for intervention and make things difficult
+for the prime minister he is faced with mortons fork if he supports action then it will be difficult
+to condemn russian interference if he counsels inaction then he risk appearing weak and callous at
+home and abroad it may appear unfortunate that our political leaders are unable to agree on policy
+strategy or tactics and it is true that this could lead to confusion about our aims but on
+reflection i think that the public disagreement between gladstone and disraeli presents an
+opportunity their dispute conducted in parliament and the press demonstrates to the world the two
+faces of the empire at the same time morally engaged and yet prudent this may allow us to proceed
+with discretion to try to influence the actors and to direct the play away from the glare of the
+footlights it may be possible to engage the league of the three emperors to our causebismarck is
+particularly keen to maintain a balance of power in the region and to avoid further war and he will
+not need to be convinced that an unbridled russia is not to his advantage so i think we can rely on
+him to rein in russias expansionary visionon the other hand the league itself may present a longer
+term threat to the empire given the breadth of its influence in northern europe and we must tread
+carefullythe emperors envoys will be meeting in reichstadt soon to determine the response to the
+crisis and i need a plan to influence the outcome as always our strategy must be to sow confusion
+and on this i plan to ask for advice from baron playfair he has recently concluded his commission of
+enquiry into the civil service and if anyone knows how to control an agenda it must be our own civil
+servants
\ No newline at end of file