Done challenge 2
authorNeil Smith <neil.git@njae.me.uk>
Thu, 12 Oct 2017 17:20:29 +0000 (18:20 +0100)
committerNeil Smith <neil.git@njae.me.uk>
Thu, 12 Oct 2017 17:20:29 +0000 (18:20 +0100)
2017/2017-challenge2.ipynb [new file with mode: 0644]
2017/2a.ciphertext [new file with mode: 0644]
2017/2a.plaintext [new file with mode: 0644]
2017/2b.ciphertext [new file with mode: 0644]
2017/2b.plaintext [new file with mode: 0644]

diff --git a/2017/2017-challenge2.ipynb b/2017/2017-challenge2.ipynb
new file mode 100644 (file)
index 0000000..4f5eae3
--- /dev/null
@@ -0,0 +1,432 @@
+{
+ "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) \n",
+    "\n",
+    "import matplotlib.pyplot as plt\n",
+    "%matplotlib inline\n",
+    "\n",
+    "from cipherbreak import *\n",
+    "\n",
+    "ca = open('2a.ciphertext').read()\n",
+    "cb = open('2b.ciphertext').read()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 7,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "(14, -3007.03777360488)"
+      ]
+     },
+     "execution_count": 7,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "key_a, score = caesar_break(ca)\n",
+    "key_a, score"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 8,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "GOSSB,\n",
+      "H OL XASB FSOVAEWK EPS VGA EHKA PN IPDHA. EPKKPYHNF BPWS VHQPEE OMPWV GAS VSOXAK YA VSOUJAD GAS VP O MPPJ VSODAS HN AK-JGOKHKH TPWJ,  QWV O VOHK PN GAS OND H GOXA MAAN UOSSBHNF PWV O EAY MOUJFSPWND UGAUJT PE LB PYN. KHJA BPW H EPWND KHVVKA VP SOHTA LB TWTQHUHPNT, OND, FHXAN GAS QSPEATTHPN, VGASA HT NPVGHNF WNWTWOK OMPWV GAS MAHNF GASA HN UOHSP. TGA TAALT VP MA YAKK JNPYN, YAKK KHJAD, OND LPTV HLQPSVONVKB, YAKK VSWTVAD. HE YA GOD NPVGHNF AKTA VP FP PN H VPP YPWKD GOXA YSHVVAN GAS PEE OT O KAOD, GPYAXAS VYP DOBT OFP LB OFANVT KPTV VSOUJ PE GAS OND TGA DHTOQQAOSAD.\n",
+      "YA SON OKK VGA WTWOK UGAUJT OND EPWND GAS HN UKAPQOVSO GPTQHVOK, SAUPXASHNF ESPL ON OTTOWKV. VGA KPUOK TVOVHPN QSPUWSAD USADANVHOKT OND UPXAS EPS LA OT O KPUOK DAVAUVHXA OND H UOSSHAD PWV O TVONDOSD EHAKD HNVASXHAY YGHUG GOT FHXAN WT O GAODTVOSV PN VGA HNXATVHFOVHPN. IPDHA'T LHTEPSVWNA HT LB KWUJ.\n",
+      "TGA HT GASA VP VSOUJ DPYN O DPUWLANV OQQOSANVKB YSHVVAN MB VGA SPLON GHTVPSHON VOUHVWT. VGA GWNV EPS VGA MPPJ TVOSVAD YGAN TPLAPNA EPWND O DPUWLANV HN VGA XOVHUON KHMSOSB YSHVVAN MB KO VPWSAV. HV HNUKWDAD AZVSOUVT ESPL O KOVHN DPUWLANV VGOV OQQAOSAD VP MA ON ADHVAD XASTHPN PE VGA OFSHUPKO OND IPDHA VAKKT LA VGOV VGA TVBKA YOT SAUPFNHTOMKB VOUHVWT, OND TPLA PE VGA TANVANUAT YASA VGA TOLA OT JNPYN XASTHPNT PE VGA PSHFHNOK. GPYAXAS VGASA YASA O EAY THFNHEHUONV UGONFAT OND IPDHA VSOXAKKAD VP SPLA VP TAOSUG EPS LPSA. HN VGA OSUGHXAT TGA EPWND VOUHVWT' DAOVGMAD UPNEATTHPN YGHUG SAEASSAD VP O DPUWLANV TP TGPUJHNF VGOV VOUHVWT GHLTAKE GOD PSDASAD HV VP MA TQKHV WQ OND UPNUAOKAD OUSPTT O NWLMAS PE THVAT HN VGA ONUHANV YPSKD. NP UKWAT YASA FHXAN VP VGA NOVWSA PE VGA THVAT, MWV VGA DPUWLANV UPNUKWDAD YHVG VGA TVOVALANV \"LB KAFOUB YHKK MA O VSWVG YGHUG PWVKOTVT VGA LPWNVOHN PE FPDT YGHUG FWOSDT HVT FOVAYOB\". VGHT KAD IPDHA VP TWTQAUV VGOV VGA QBSOLHDT OV FHCO YASA O FPPD QKOUA VP TVOSV. VGOV YOT YGASA TGA YOT OVVOUJAD.\n",
+      "HV VPPJ IPDHA VGSAA DOBT VP EHND VGA DPUWLANV GHDDAN OLPNF VGA TVPNAT, OND LB FWATT HT VGOV TPLAPNA YOT YOVUGHNF GAS WNVHK TGA EPWND HV KOVA PN VGA VGHSD DOB. TGA PNKB GOD HV EPS EHXA LHNWVAT MAEPSA TGA YOT SPMMAD, MWV TGA LODA VGA LPTV PE VGOV VHLA, QGPVPFSOQGHNF VGA ESOFLANV. VGA OVVOUJAST VPPJ GAS QGPNA, MWV VGA HLOFA GOD OKSAODB WQKPODAD VP VGA UKPWD, TP OV KAOTV YA JNPY YGOV HV TOHD. QASGOQT LPSA HLQPSVONVKB YA LOB GOXA ONPVGAS UKWA VP VGA KPUOVHPN PE VGA NAZV ESOFLANV, \"VGA EWKK VSWVG LWTV SALOHN GHDDAN EPS NPY, OND OT SALOSJAD MB LB VSWTVAD TKOXA OND UPNEHDONV VHSP, YGOV MAVVAS QKOUA VP GHDA O MPPJ VGON OLPNF MPPJT?\"\n",
+      "\n"
+     ]
+    }
+   ],
+   "source": [
+    "print(caesar_decipher(ca, key_a))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 9,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "((5, 16, True), -2842.001592719175)"
+      ]
+     },
+     "execution_count": 9,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "(m_a, a_a, o_a), score = affine_break(ca)\n",
+    "(m_a, a_a, o_a), score"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 10,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "AMSSZ,\n",
+      "V MB TESZ FSMDEKYG KHS DAE KVGE HR QHPVE. KHGGHOVRF ZHYS DVCHKK MWHYD AES DSMTEG OE DSMILEP AES DH M WHHL DSMPES VR EG-LAMGVGV NHYL,  CYD M DMVG HR AES MRP V AMTE WEER IMSSZVRF HYD M KEO WMILFSHYRP IAEILN HK BZ HOR. GVLE ZHY V KHYRP GVDDGE DH SMVNE BZ NYNCVIVHRN, MRP, FVTER AES CSHKENNVHR, DAESE VN RHDAVRF YRYNYMG MWHYD AES WEVRF AESE VR IMVSH. NAE NEEBN DH WE OEGG LRHOR, OEGG GVLEP, MRP BHND VBCHSDMRDGZ, OEGG DSYNDEP. VK OE AMP RHDAVRF EGNE DH FH HR V DHH OHYGP AMTE OSVDDER AES HKK MN M GEMP, AHOETES DOH PMZN MFH BZ MFERDN GHND DSMIL HK AES MRP NAE PVNMCCEMSEP.\n",
+      "OE SMR MGG DAE YNYMG IAEILN MRP KHYRP AES VR IGEHCMDSM AHNCVDMG, SEIHTESVRF KSHB MR MNNMYGD. DAE GHIMG NDMDVHR CSHIYSEP ISEPERDVMGN MRP IHTES KHS BE MN M GHIMG PEDEIDVTE MRP V IMSSVEP HYD M NDMRPMSP KVEGP VRDESTVEO OAVIA AMN FVTER YN M AEMPNDMSD HR DAE VRTENDVFMDVHR. QHPVE'N BVNKHSDYRE VN BZ GYIL.\n",
+      "NAE VN AESE DH DSMIL PHOR M PHIYBERD MCCMSERDGZ OSVDDER WZ DAE SHBMR AVNDHSVMR DMIVDYN. DAE AYRD KHS DAE WHHL NDMSDEP OAER NHBEHRE KHYRP M PHIYBERD VR DAE TMDVIMR GVWSMSZ OSVDDER WZ GM DHYSED. VD VRIGYPEP EJDSMIDN KSHB M GMDVR PHIYBERD DAMD MCCEMSEP DH WE MR EPVDEP TESNVHR HK DAE MFSVIHGM MRP QHPVE DEGGN BE DAMD DAE NDZGE OMN SEIHFRVNMWGZ DMIVDYN, MRP NHBE HK DAE NERDERIEN OESE DAE NMBE MN LRHOR TESNVHRN HK DAE HSVFVRMG. AHOETES DAESE OESE M KEO NVFRVKVIMRD IAMRFEN MRP QHPVE DSMTEGGEP DH SHBE DH NEMSIA KHS BHSE. VR DAE MSIAVTEN NAE KHYRP DMIVDYN’ PEMDAWEP IHRKENNVHR OAVIA SEKESSEP DH M PHIYBERD NH NAHILVRF DAMD DMIVDYN AVBNEGK AMP HSPESEP VD DH WE NCGVD YC MRP IHRIEMGEP MISHNN M RYBWES HK NVDEN VR DAE MRIVERD OHSGP. RH IGYEN OESE FVTER DH DAE RMDYSE HK DAE NVDEN, WYD DAE PHIYBERD IHRIGYPEP OVDA DAE NDMDEBERD “BZ GEFMIZ OVGG WE M DSYDA OAVIA HYDGMNDN DAE BHYRDMVR HK FHPN OAVIA FYMSPN VDN FMDEOMZ“. DAVN GEP QHPVE DH NYNCEID DAMD DAE CZSMBVPN MD FVUM OESE M FHHP CGMIE DH NDMSD. DAMD OMN OAESE NAE OMN MDDMILEP.\n",
+      "VD DHHL QHPVE DASEE PMZN DH KVRP DAE PHIYBERD AVPPER MBHRF DAE NDHREN, MRP BZ FYENN VN DAMD NHBEHRE OMN OMDIAVRF AES YRDVG NAE KHYRP VD GMDE HR DAE DAVSP PMZ. NAE HRGZ AMP VD KHS KVTE BVRYDEN WEKHSE NAE OMN SHWWEP, WYD NAE BMPE DAE BHND HK DAMD DVBE, CAHDHFSMCAVRF DAE KSMFBERD. DAE MDDMILESN DHHL AES CAHRE, WYD DAE VBMFE AMP MGSEMPZ YCGHMPEP DH DAE IGHYP, NH MD GEMND OE LRHO OAMD VD NMVP. CESAMCN BHSE VBCHSDMRDGZ OE BMZ AMTE MRHDAES IGYE DH DAE GHIMDVHR HK DAE REJD KSMFBERD, “DAE KYGG DSYDA BYND SEBMVR AVPPER KHS RHO, MRP MN SEBMSLEP WZ BZ DSYNDEP NGMTE MRP IHRKVPMRD DVSH, OAMD WEDDES CGMIE DH AVPE M WHHL DAMR MBHRF WHHLN?”\n",
+      "\n"
+     ]
+    }
+   ],
+   "source": [
+    "print(affine_decipher(ca, m_a, a_a, o_a))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 12,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "(('cairo', <KeywordWrapAlphabet.from_largest: 3>), -2538.6915458754715)"
+      ]
+     },
+     "execution_count": 12,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "(key_word, key_wrap), score = keyword_break_mp(ca)\n",
+    "(key_word, key_wrap), score"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 14,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "harry,\n",
+      "i am very grateful for the file on jodie. following your tipoff about her travel we tracked her to a book trader in el-khalili souk,  put a tail on her and i have been carrying out a few background checks of my own. like you i found little to raise my suspicions, and, given her profession, there is nothing unusual about her being here in cairo. she seems to be well known, well liked, and most importantly, well trusted. if we had nothing else to go on i too would have written her off as a lead, however two days ago my agents lost track of her and she disappeared.\n",
+      "we ran all the usual checks and found her in cleopatra hospital, recovering from an assault. the local station procured credentials and cover for me as a local detective and i carried out a standard field interview which has given us a headstart on the investigation. jodie's misfortune is my luck.\n",
+      "she is here to track down a document apparently written by the roman historian tacitus. the hunt for the book started when someone found a document in the vatican library written by la touret. it included extracts from a latin document that appeared to be an edited version of the agricola and jodie tells me that the style was recognisably tacitus, and some of the sentences were the same as known versions of the original. however there were a few significant changes and jodie travelled to rome to search for more. in the archives she found tacitus’ deathbed confession which referred to a document so shocking that tacitus himself had ordered it to be split up and concealed across a number of sites in the ancient world. no clues were given to the nature of the sites, but the document concluded with the statement “my legacy will be a truth which outlasts the mountain of gods which guards its gateway“. this led jodie to suspect that the pyramids at giza were a good place to start. that was where she was attacked.\n",
+      "it took jodie three days to find the document hidden among the stones, and my guess is that someone was watching her until she found it late on the third day. she only had it for five minutes before she was robbed, but she made the most of that time, photographing the fragment. the attackers took her phone, but the image had already uploaded to the cloud, so at least we know what it said. perhaps more importantly we may have another clue to the location of the next fragment, “the full truth must remain hidden for now, and as remarked by my trusted slave and confidant tiro, what better place to hide a book than among books?”\n",
+      "\n"
+     ]
+    }
+   ],
+   "source": [
+    "print(keyword_decipher(ca, key_word, key_wrap))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 15,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "2530"
+      ]
+     },
+     "execution_count": 15,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "open('2a.plaintext', 'w').write(keyword_decipher(ca, key_word, key_wrap))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 16,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "(0, -2059.1045635741802)"
+      ]
+     },
+     "execution_count": 16,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "key_b, score = caesar_break(cb)\n",
+    "key_b, score"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 17,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'tel uutrfetnehioyitbephn da he i ood rul tie rate fre haedugsioafdeiielcgn esr pine oe reo on rhftodcrdvlsrvtdbtm moss an fnsrwturawteernofgvp uhehloastieeaooenxih btn rees tv armed hb lccelrocshnpicctvvbu a esd adam a at ids neat res at mwr oitdteoafutoteeiltiu song lro a ae alle of lts htnirwtalnrdornnef sort y ont frith lee doer do i gewitneeyolivmedttud are on du th gti set tfbrosfnrtmrutlkwg to dinu do by rfr deot tut see e ov yeeeah yau at fdot a i at rec ihfnhpaouerseselupsh lsr to wcg to eu to at raoeceyvteeeiadesmaw aetna ihieysrlemritmtchrei or nh et stop eeg mhi hau at bal of uno ho is hceoirnsdgasbboohaes ileaigageefiwgtyhwuh tue ruts held ei on oe fniienhosasnoueiytih net tsnfbsueihossiurdenl md oh yom re a as i wst gmt nrao ocmfihlnaedcariwrrd tel nsgjerurncsoegttlfca a tri rels sri do eeo ssi knuth ndt ltnribbaadsehyetppbo am thd neg epic nj chf ciypiuireectlsdewodc ter fi set et dnntgabopgsenlaaodc bed htrmoelrserruuevstrw id ftb as bott tah wear o lori bnc kg mft to cree vt seb nmr ur heed see sioylsioeuoioroubtao cneacaadlttnndeobeea niue yu cee dc no in ich mm tte oyaauwerodolstiiheiy pro hltvoueeoisdpuoiohlr hla iaea du loel pepa ahnohtarnuiibcdtsh set uaihulalcnooefawo an rene hhreuvecfdoidotrwlrr tslsa iv uta ebi i hi a heat scc we sdetwihntehettuuohh teidvttereoybcsttehh need tart to dau maes gaed muurveoxnssftnnmiehn note to svbolrhwebuentvdsrs cleb gats us do to a ihl nst nish doo a lee hon rsc pstn i this pdb nc soes ft nei see sebi wtewuretnyltaadeutdd noce ruh a edie le marino c insmod an few si see ocle lroefcldhiaatihoeaw der hls etna cyan mhoaihtftahacoehaes lrtwkeodnltehhonbnqo at hhaeltnjbrnihutinltz ctrn copes mag flo en tures n led an env n he an i eio set r the hm faa co arni uri guoesneeethdntuowpg afc eng us ie it esoeosrtebcefrnhutr fiigs das ah pate due retd berr tec in hey serr end is sdet dmo css pres gei eu ups erath ferfbceoacsmhsefgq at eaettlwttoavteefepao aol as oee et to ie i int fay lo lee fs'"
+      ]
+     },
+     "execution_count": 17,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "wcat(segment(sanitise(caesar_decipher(cb, key_b))))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 18,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "((1, 0, True), -2059.1045635741802)"
+      ]
+     },
+     "execution_count": 18,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "(m_b, a_b, o_b), score = affine_break(cb)\n",
+    "(m_b, a_b, o_b), score"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 20,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "teluutrfetnehioyitbephndaheioodrultieratefrehaedugsioafdeiielcgnesrpineoereoonrhftodcrdvlsrvtdbtmmossanfnsrwturawteernofgvpuhehloastieeaooenxihbtnreestvarmedhblccelrocshnpicctvvbuaesdadamaatidsneatresatmwroitdteoafutoteeiltiusonglroaaealleofltshtnirwtalnrdornnefsortyontfrithleedoerdoigewitneeyolivmedttudareonduthgtisettfbrosfnrtmrutlkwgtodinudobyrfrdeottutseeeovyeeeahyauatfdotaiatrecihfnhpaouerseselupshlsrtowcgtoeutoatraoeceyvteeeiadesmawaetnaihieysrlemritmtchreiornhetstopeegmhihauatbalofunohoishceoirnsdgasbboohaesileaigageefiwgtyhwuhtuerutsheldeionoefniienhosasnoueiytihnettsnfbsueihossiurdenlmdohyomreaasiwstgmtnraoocmfihlnaedcariwrrdtelnsgjerurncsoegttlfcaatrirelssridoeeossiknuthndtltnribbaadsehyetppboamthdnegepicnjchfciypiuireectlsdewodcterfisetetdnntgabopgsenlaaodcbedhtrmoelrserruuevstrwidftbasbotttahwearoloribnckgmfttocreevtsebnmrurheedseesioylsioeuoioroubtaocneacaadlttnndeobeeaniueyuceedcnoinichmmtteoyaauwerodolstiiheiyprohltvoueeoisdpuoiohlrhlaiaeaduloelpepaahnohtarnuiibcdtshsetuaihulalcnooefawoanrenehhreuvecfdoidotrwlrrtslsaivutaebiihiaheatsccwesdetwihntehettuuohhteidvttereoybcsttehhneedtarttodaumaesgaedmuurveoxnssftnnmiehnnotetosvbolrhwebuentvdsrsclebgatsusdotoaihlnstnishdooaleehonrscpstnithispdbncsoesftneiseesebiwtewuretnyltaadeutddnoceruhaedielemarinocinsmodanfewsiseeoclelroefcldhiaatihoeawderhlsetnacyanmhoaihtftahacoehaeslrtwkeodnltehhonbnqoathhaeltnjbrnihutinltzctrncopesmagfloenturesnledanenvnheanieiosetrthehmfaacoarniuriguoesneeethdntuowpgafcengusieitesoeosrtebcefrnhutrfiigsdasahpatedueretdberrtecinheyserrendissdetdmocsspresgeieuupserathferfbceoacsmhsefgqateaettlwttoavteefepaoaolasoeeettoieiintfayloleefs\n"
+     ]
+    }
+   ],
+   "source": [
+    "print(affine_decipher(sanitise(cb), m_b, a_b, o_b))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 25,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "teluutrfet\n",
+      "hleedoerdo\n",
+      "eldeionoef\n",
+      "ribnckgmft\n",
+      "eoybcstteh\n",
+      "bnqoathhae\n"
+     ]
+    }
+   ],
+   "source": [
+    "for r in cb.split('\\n'):\n",
+    "    print(sanitise(r)[:10])"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 39,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'the rebellion led by queen boudicca took strength from the defeat of the ninth legion the iceni were joined by the trinovantes tribe as they setup on both londinium and verulam ium they razed the cities to the ground and desecrated our temples suetonius informed by varus legatus of the ix legion of the seriousness of the situation returned from subduing rebels on the island of mona and confronted the enemy at viro conium a she travelled back along watling street in his own words despite being outnumbered ten to one the bravery and heroism of our forces and my careful choice of the battleground and tactics ensured our decisive and glorious victory whoever masterminded the battle the enemy lost many thousands against just a few hundred of our own troops and agricola was left to secure the region acting with ruthless efficiency perhaps in part to at one for his guilt over the previous loss he supressed the rebellion boudicca possessed of the perilous ness of her situation took her own life cursing the ixth legion as she died but a battle is not a war and the true peril was about to be revealed a captured enemy spy revealed that they had be enable to decipher captured battle orders and communications which had been encrypted using the caesar cipher this device invented by julius caesar himself had secured military and diplomatic communications across the empire for decades it was no longer safe and neither were we suetonius s despatches to the emperor were careful to give himself the credit for the defeat of boudicca and left no doubt that agricola was to blame for the uprising the loss of the legions aquila was said to have encouraged the local tribes to rebel and it was hinted that agricola may also have been to blame for the loss of the caesar cipher what suetonius failed to reveal was that it was agricola who engineered the defeat of the tribes on watling street but if you wish to know the truth of that day then you will need to travel further to the isle of thorns'"
+      ]
+     },
+     "execution_count": 39,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "wcat(segment(cat(cat(zr) for zr in zip(*[sanitise(r) for r in cb.split('\\n')]))))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 24,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "274"
+      ]
+     },
+     "execution_count": 24,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "len(sanitise(cb.split('\\n')[0]))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 33,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "6"
+      ]
+     },
+     "execution_count": 33,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "len(cb.split('\\n'))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 31,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'the rebellion led by queen boudicca took strength from the defeat of the ninth legion the iceni were joined by the trinovantes tribe as they setup on both londinium and verulam ium they razed the cities to the ground and desecrated our temples suetonius informed by varus legatus of the ix legion of the seriousness of the situation returned from subduing rebels on the island of mona and confronted the enemy at viro conium a she travelled back along watling street in his own words despite being outnumbered ten to one the bravery and heroism of our forces and my careful choice of the battleground and tactics ensured our decisive and glorious victory whoever masterminded the battle the enemy lost many thousands against just a few hundred of our own troops and agricola was left to secure the region acting with ruthless efficiency perhaps in part to at one for his guilt over the previous loss he supressed the rebellion boudicca possessed of the perilous ness of her situation took her own life cursing the ixth legion as she died but a battle is not a war and the true peril was about to be revealed a captured enemy spy revealed that they had be enable to decipher captured battle orders and communications which had been encrypted using the caesar cipher this device invented by julius caesar himself had secured military and diplomatic communications across the empire for decades it was no longer safe and neither were we suetonius s despatches to the emperor were careful to give himself the credit for the defeat of boudicca and left no doubt that agricola was to blame for the uprising the loss of the legions aquila was said to have encouraged the local tribes to rebel and it was hinted that agricola may also have been to blame for the loss of the caesar cipher what suetonius failed to reveal was that it was agricola who engineered the defeat of the tribes on watling street but if you wish to know the truth of that day then you will need to travel further to the isle of thorns'"
+      ]
+     },
+     "execution_count": 31,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "wcat(segment(column_transposition_decipher(sanitise(cb), \n",
+    "                                           tuple(range(274)), \n",
+    "                                           fillcolumnwise=True, \n",
+    "                                           emptycolumnwise=False)))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 34,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'the rebellion led by queen boudicca took strength from the defeat of the ninth legion the iceni were joined by the trinovantes tribe as they setup on both londinium and verulam ium they razed the cities to the ground and desecrated our temples suetonius informed by varus legatus of the ix legion of the seriousness of the situation returned from subduing rebels on the island of mona and confronted the enemy at viro conium a she travelled back along watling street in his own words despite being outnumbered ten to one the bravery and heroism of our forces and my careful choice of the battleground and tactics ensured our decisive and glorious victory whoever masterminded the battle the enemy lost many thousands against just a few hundred of our own troops and agricola was left to secure the region acting with ruthless efficiency perhaps in part to at one for his guilt over the previous loss he supressed the rebellion boudicca possessed of the perilous ness of her situation took her own life cursing the ixth legion as she died but a battle is not a war and the true peril was about to be revealed a captured enemy spy revealed that they had be enable to decipher captured battle orders and communications which had been encrypted using the caesar cipher this device invented by julius caesar himself had secured military and diplomatic communications across the empire for decades it was no longer safe and neither were we suetonius s despatches to the emperor were careful to give himself the credit for the defeat of boudicca and left no doubt that agricola was to blame for the uprising the loss of the legions aquila was said to have encouraged the local tribes to rebel and it was hinted that agricola may also have been to blame for the loss of the caesar cipher what suetonius failed to reveal was that it was agricola who engineered the defeat of the tribes on watling street but if you wish to know the truth of that day then you will need to travel further to the isle of thorns'"
+      ]
+     },
+     "execution_count": 34,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "wcat(segment(column_transposition_decipher(sanitise(cb), \n",
+    "                                           tuple(range(6)), \n",
+    "                                           fillcolumnwise=False, \n",
+    "                                           emptycolumnwise=True)))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 32,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "1999"
+      ]
+     },
+     "execution_count": 32,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "open('2b.plaintext', 'w').write(wcat(segment(column_transposition_decipher(sanitise(cb), \n",
+    "                                           tuple(range(274)), \n",
+    "                                           fillcolumnwise=True, \n",
+    "                                           emptycolumnwise=False))))"
+   ]
+  },
+  {
+   "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.5.3"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/2017/2a.ciphertext b/2017/2a.ciphertext
new file mode 100644 (file)
index 0000000..9003966
--- /dev/null
@@ -0,0 +1,5 @@
+UCGGP,
+V CZ LOGP TGCJOSKY SDG JUO SVYO DB WDRVO. SDYYDMVBT PDKG JVEDSS CADKJ UOG JGCLOY MO JGCIXOR UOG JD C ADDX JGCROG VB OY-XUCYVYV HDKX,  EKJ C JCVY DB UOG CBR V UCLO AOOB ICGGPVBT DKJ C SOM ACIXTGDKBR IUOIXH DS ZP DMB. YVXO PDK V SDKBR YVJJYO JD GCVHO ZP HKHEVIVDBH, CBR, TVLOB UOG EGDSOHHVDB, JUOGO VH BDJUVBT KBKHKCY CADKJ UOG AOVBT UOGO VB ICVGD. HUO HOOZH JD AO MOYY XBDMB, MOYY YVXOR, CBR ZDHJ VZEDGJCBJYP, MOYY JGKHJOR. VS MO UCR BDJUVBT OYHO JD TD DB V JDD MDKYR UCLO MGVJJOB UOG DSS CH C YOCR, UDMOLOG JMD RCPH CTD ZP CTOBJH YDHJ JGCIX DS UOG CBR HUO RVHCEEOCGOR.
+MO GCB CYY JUO KHKCY IUOIXH CBR SDKBR UOG VB IYODECJGC UDHEVJCY, GOIDLOGVBT SGDZ CB CHHCKYJ. JUO YDICY HJCJVDB EGDIKGOR IGOROBJVCYH CBR IDLOG SDG ZO CH C YDICY ROJOIJVLO CBR V ICGGVOR DKJ C HJCBRCGR SVOYR VBJOGLVOM MUVIU UCH TVLOB KH C UOCRHJCGJ DB JUO VBLOHJVTCJVDB. WDRVO'H ZVHSDGJKBO VH ZP YKIX.
+HUO VH UOGO JD JGCIX RDMB C RDIKZOBJ CEECGOBJYP MGVJJOB AP JUO GDZCB UVHJDGVCB JCIVJKH. JUO UKBJ SDG JUO ADDX HJCGJOR MUOB HDZODBO SDKBR C RDIKZOBJ VB JUO LCJVICB YVAGCGP MGVJJOB AP YC JDKGOJ. VJ VBIYKROR ONJGCIJH SGDZ C YCJVB RDIKZOBJ JUCJ CEEOCGOR JD AO CB ORVJOR LOGHVDB DS JUO CTGVIDYC CBR WDRVO JOYYH ZO JUCJ JUO HJPYO MCH GOIDTBVHCAYP JCIVJKH, CBR HDZO DS JUO HOBJOBIOH MOGO JUO HCZO CH XBDMB LOGHVDBH DS JUO DGVTVBCY. UDMOLOG JUOGO MOGO C SOM HVTBVSVICBJ IUCBTOH CBR WDRVO JGCLOYYOR JD GDZO JD HOCGIU SDG ZDGO. VB JUO CGIUVLOH HUO SDKBR JCIVJKH’ ROCJUAOR IDBSOHHVDB MUVIU GOSOGGOR JD C RDIKZOBJ HD HUDIXVBT JUCJ JCIVJKH UVZHOYS UCR DGROGOR VJ JD AO HEYVJ KE CBR IDBIOCYOR CIGDHH C BKZAOG DS HVJOH VB JUO CBIVOBJ MDGYR. BD IYKOH MOGO TVLOB JD JUO BCJKGO DS JUO HVJOH, AKJ JUO RDIKZOBJ IDBIYKROR MVJU JUO HJCJOZOBJ “ZP YOTCIP MVYY AO C JGKJU MUVIU DKJYCHJH JUO ZDKBJCVB DS TDRH MUVIU TKCGRH VJH TCJOMCP“. JUVH YOR WDRVO JD HKHEOIJ JUCJ JUO EPGCZVRH CJ TVQC MOGO C TDDR EYCIO JD HJCGJ. JUCJ MCH MUOGO HUO MCH CJJCIXOR.
+VJ JDDX WDRVO JUGOO RCPH JD SVBR JUO RDIKZOBJ UVRROB CZDBT JUO HJDBOH, CBR ZP TKOHH VH JUCJ HDZODBO MCH MCJIUVBT UOG KBJVY HUO SDKBR VJ YCJO DB JUO JUVGR RCP. HUO DBYP UCR VJ SDG SVLO ZVBKJOH AOSDGO HUO MCH GDAAOR, AKJ HUO ZCRO JUO ZDHJ DS JUCJ JVZO, EUDJDTGCEUVBT JUO SGCTZOBJ. JUO CJJCIXOGH JDDX UOG EUDBO, AKJ JUO VZCTO UCR CYGOCRP KEYDCROR JD JUO IYDKR, HD CJ YOCHJ MO XBDM MUCJ VJ HCVR. EOGUCEH ZDGO VZEDGJCBJYP MO ZCP UCLO CBDJUOG IYKO JD JUO YDICJVDB DS JUO BONJ SGCTZOBJ, “JUO SKYY JGKJU ZKHJ GOZCVB UVRROB SDG BDM, CBR CH GOZCGXOR AP ZP JGKHJOR HYCLO CBR IDBSVRCBJ JVGD, MUCJ AOJJOG EYCIO JD UVRO C ADDX JUCB CZDBT ADDXH?”
diff --git a/2017/2a.plaintext b/2017/2a.plaintext
new file mode 100644 (file)
index 0000000..e59b963
--- /dev/null
@@ -0,0 +1,5 @@
+harry,
+i am very grateful for the file on jodie. following your tipoff about her travel we tracked her to a book trader in el-khalili souk,  put a tail on her and i have been carrying out a few background checks of my own. like you i found little to raise my suspicions, and, given her profession, there is nothing unusual about her being here in cairo. she seems to be well known, well liked, and most importantly, well trusted. if we had nothing else to go on i too would have written her off as a lead, however two days ago my agents lost track of her and she disappeared.
+we ran all the usual checks and found her in cleopatra hospital, recovering from an assault. the local station procured credentials and cover for me as a local detective and i carried out a standard field interview which has given us a headstart on the investigation. jodie's misfortune is my luck.
+she is here to track down a document apparently written by the roman historian tacitus. the hunt for the book started when someone found a document in the vatican library written by la touret. it included extracts from a latin document that appeared to be an edited version of the agricola and jodie tells me that the style was recognisably tacitus, and some of the sentences were the same as known versions of the original. however there were a few significant changes and jodie travelled to rome to search for more. in the archives she found tacitus’ deathbed confession which referred to a document so shocking that tacitus himself had ordered it to be split up and concealed across a number of sites in the ancient world. no clues were given to the nature of the sites, but the document concluded with the statement “my legacy will be a truth which outlasts the mountain of gods which guards its gateway“. this led jodie to suspect that the pyramids at giza were a good place to start. that was where she was attacked.
+it took jodie three days to find the document hidden among the stones, and my guess is that someone was watching her until she found it late on the third day. she only had it for five minutes before she was robbed, but she made the most of that time, photographing the fragment. the attackers took her phone, but the image had already uploaded to the cloud, so at least we know what it said. perhaps more importantly we may have another clue to the location of the next fragment, “the full truth must remain hidden for now, and as remarked by my trusted slave and confidant tiro, what better place to hide a book than among books?”
diff --git a/2017/2b.ciphertext b/2017/2b.ciphertext
new file mode 100644 (file)
index 0000000..c4e454d
--- /dev/null
@@ -0,0 +1,6 @@
+T   E   L   U   U   T   R   F   E   T   N   E   H   I   O   Y   I   T   B   E   P   H   N   D   A   H   E   I   O   O   D   R   U   L   T   I   E   R   A   T   E   F   R   E   H   A   E   D   U   G   S   I   O   A   F   D   E   I   I   E   L   C   G   N   E   S   R   P   I   N   E   O   E   R   E   O   O   N   R   H   F   T   O   D   C   R   D   V   L   S   R   V   T   D   B   T   M   M   O   S   S   A   N   F   N   S   R   W   T   U   R   A   W   T   E   E   R   N   O   F   G   V   P   U   H   E   H   L   O   A   S   T   I   E   E   A   O   O   E   N   X   I   H   B   T   N   R   E   E   S   T   V   A   R   M   E   D   H   B   L   C   C   E   L   R   O   C   S   H   N   P   I   C   C   T   V   V   B   U   A   E   S   D   A   D   A   M   A   A   T   I   D   S   N   E   A   T   R   E   S   A   T   M   W   R   O   I   T   D   T   E   O   A   F   U   T   O   T   E   E   I   L   T   I   U   S   O   N   G   L   R   O   A   A   E   A   L   L   E   O   F   L   T   S   H   T   N   I   R   W   T   A   L   N   R   D   O   R   N   N   E   F   S   O   R   T   Y   O   N   T   F   R   I   T
+H   L   E   E   D   O   E   R   D   O   I   G   E   W   I   T   N   E   E   Y   O   L   I   V   M   E   D   T   T   U   D   A   R   E   O   N   D   U   T   H   G   T   I   S   E   T   T   F   B   R   O   S   F   N   R   T   M   R   U   T   L   K   W   G   T   O   D   I   N   U   D   O   B   Y   R   F   R   D   E   O   T   T   U   T   S   E   E   E   O   V   Y   E   E   E   A   H   Y   A   U   A   T   F   D   O   T   A   I   A   T   R   E   C   I   H   F   N   H   P   A   O   U   E   R   S   E   S   E   L   U   P   S   H   L   S   R   T   O   W   C   G   T   O   E   U   T   O   A   T   R   A   O   E   C   E   Y   V   T   E   E   E   I   A   D   E   S   M   A   W   A   E   T   N   A   I   H   I   E   Y   S   R   L   E   M   R   I   T   M   T   C   H   R   E   I   O   R   N   H   E   T   S   T   O   P   E   E   G   M   H   I   H   A   U   A   T   B   A   L   O   F   U   N   O   H   O   I   S   H   C   E   O   I   R   N   S   D   G   A   S   B   B   O   O   H   A   E   S   I   L   E   A   I   G   A   G   E   E   F   I   W   G   T   Y   H   W   U   H   T   U   E   R   U   T   S   H
+E   L   D   E   I   O   N   O   E   F   N   I   I   E   N   H   O   S   A   S   N   O   U   E   I   Y   T   I   H   N   E   T   T   S   N   F   B   S   U   E   I   H   O   S   S   I   U   R   D   E   N   L   M   D   O   H   Y   O   M   R   E   A   A   S   I   W   S   T   G   M   T   N   R   A   O   O   C   M   F   I   H   L   N   A   E   D   C   A   R   I   W   R   R   D   T   E   L   N   S   G   J   E   R   U   R   N   C   S   O   E   G   T   T   L   F   C   A   A   T   R   I   R   E   L   S   S   R   I   D   O   E   E   O   S   S   I   K   N   U   T   H   N   D   T   L   T   N   R   I   B   B   A   A   D   S   E   H   Y   E   T   P   P   B   O   A   M   T   H   D   N   E   G   E   P   I   C   N   J   C   H   F   C   I   Y   P   I   U   I   R   E   E   C   T   L   S   D   E   W   O   D   C   T   E   R   F   I   S   E   T   E   T   D   N   N   T   G   A   B   O   P   G   S   E   N   L   A   A   O   D   C   B   E   D   H   T   R   M   O   E   L   R   S   E   R   R   U   U   E   V   S   T   R   W   I   D   F   T   B   A   S   B   O   T   T   T   A   H   W   E   A   R   O   L   O
+R   I   B   N   C   K   G   M   F   T   T   O   C   R   E   E   V   T   S   E   B   N   M   R   U   R   H   E   E   D   S   E   E   S   I   O   Y   L   S   I   O   E   U   O   I   O   R   O   U   B   T   A   O   C   N   E   A   C   A   A   D   L   T   T   N   N   D   E   O   B   E   E   A   N   I   U   E   Y   U   C   E   E   D   C   N   O   I   N   I   C   H   M   M   T   T   E   O   Y   A   A   U   W   E   R   O   D   O   L   S   T   I   I   H   E   I   Y   P   R   O   H   L   T   V   O   U   E   E   O   I   S   D   P   U   O   I   O   H   L   R   H   L   A   I   A   E   A   D   U   L   O   E   L   P   E   P   A   A   H   N   O   H   T   A   R   N   U   I   I   B   C   D   T   S   H   S   E   T   U   A   I   H   U   L   A   L   C   N   O   O   E   F   A   W   O   A   N   R   E   N   E   H   H   R   E   U   V   E   C   F   D   O   I   D   O   T   R   W   L   R   R   T   S   L   S   A   I   V   U   T   A   E   B   I   I   H   I   A   H   E   A   T   S   C   C   W   E   S   D   E   T   W   I   H   N   T   E   H   E   T   T   U   U   O   H   H   T   E   I   D   V   T   T   E   R
+E   O   Y   B   C   S   T   T   E   H   H   N   E   E   D   T   A   R   T   T   O   D   A   U   M   A   E   S   G   A   E   D   M   U   U   R   V   E   O   X   N   S   S   F   T   N   N   M   I   E   H   N   N   O   T   E   T   O   S   V   B   O   L   R   H   W   E   B   U   E   N   T   V   D   S   R   S   C   L   E   B   G   A   T   S   U   S   D   O   T   O   A   I   H   L   N   S   T   N   I   S   H   D   O   O   A   L   E   E   H   O   N   R   S   C   P   S   T   N   I   T   H   I   S   P   D   B   N   C   S   O   E   S   F   T   N   E   I   S   E   E   S   E   B   I   W   T   E   W   U   R   E   T   N   Y   L   T   A   A   D   E   U   T   D   D   N   O   C   E   R   U   H   A   E   D   I   E   L   E   M   A   R   I   N   O   C   I   N   S   M   O   D   A   N   F   E   W   S   I   S   E   E   O   C   L   E   L   R   O   E   F   C   L   D   H   I   A   A   T   I   H   O   E   A   W   D   E   R   H   L   S   E   T   N   A   C   Y   A   N   M   H   O   A   I   H   T   F   T   A   H   A   C   O   E   H   A   E   S   L   R   T   W   K   E   O   D   N   L   T   E   H   H   O   N
+B   N   Q   O   A   T   H   H   A   E   L   T   N   J   B   R   N   I   H   U   T   I   N   L   T   Z   C   T   R   N   C   O   P   E   S   M   A   G   F   L   O   E   N   T   U   R   E   S   N   L   E   D   A   N   E   N   V   N   H   E   A   N   I   E   I   O   S   E   T   R   T   H   E   H   M   F   A   A   C   O   A   R   N   I   U   R   I   G   U   O   E   S   N   E   E   E   T   H   D   N   T   U   O   W   P   G   A   F   C   E   N   G   U   S   I   E   I   T   E   S   O   E   O   S   R   T   E   B   C   E   F   R   N   H   U   T   R   F   I   I   G   S   D   A   S   A   H   P   A   T   E   D   U   E   R   E   T   D   B   E   R   R   T   E   C   I   N   H   E   Y   S   E   R   R   E   N   D   I   S   S   D   E   T   D   M   O   C   S   S   P   R   E   S   G   E   I   E   U   U   P   S   E   R   A   T   H   F   E   R   F   B   C   E   O   A   C   S   M   H   S   E   F   G   Q   A   T   E   A   E   T   T   L   W   T   T   O   A   V   T   E   E   F   E   P   A   O   A   O   L   A   S   O   E   E   E   T   T   O   I   E   I   I   N   T   F   A   Y   L   O   L   E   E   F   S
\ No newline at end of file
diff --git a/2017/2b.plaintext b/2017/2b.plaintext
new file mode 100644 (file)
index 0000000..67e9371
--- /dev/null
@@ -0,0 +1 @@
+the rebellion led by queen boudicca took strength from the defeat of the ninth legion the iceni were joined by the trinovantes tribe as they setup on both londinium and verulam ium they razed the cities to the ground and desecrated our temples suetonius informed by varus legatus of the ix legion of the seriousness of the situation returned from subduing rebels on the island of mona and confronted the enemy at viro conium a she travelled back along watling street in his own words despite being outnumbered ten to one the bravery and heroism of our forces and my careful choice of the battleground and tactics ensured our decisive and glorious victory whoever masterminded the battle the enemy lost many thousands against just a few hundred of our own troops and agricola was left to secure the region acting with ruthless efficiency perhaps in part to at one for his guilt over the previous loss he supressed the rebellion boudicca possessed of the perilous ness of her situation took her own life cursing the ixth legion as she died but a battle is not a war and the true peril was about to be revealed a captured enemy spy revealed that they had be enable to decipher captured battle orders and communications which had been encrypted using the caesar cipher this device invented by julius caesar himself had secured military and diplomatic communications across the empire for decades it was no longer safe and neither were we suetonius s despatches to the emperor were careful to give himself the credit for the defeat of boudicca and left no doubt that agricola was to blame for the uprising the loss of the legions aquila was said to have encouraged the local tribes to rebel and it was hinted that agricola may also have been to blame for the loss of the caesar cipher what suetonius failed to reveal was that it was agricola who engineered the defeat of the tribes on watling street but if you wish to know the truth of that day then you will need to travel further to the isle of thorns
\ No newline at end of file