From 837af0a78bfaf51266a1e21fbfd2baa80857d5bb Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Fri, 17 Nov 2017 11:20:40 +0000 Subject: [PATCH] Done challenge 6b, added some text formatting tools --- 2017/2017-challenge6.ipynb | 1479 ++++++++++++++++++++++++------------ 2017/6a.plaintext | 20 + cipher.py | 1 + cipherbreak.py | 12 + text_prettify.py | 61 ++ 5 files changed, 1091 insertions(+), 482 deletions(-) create mode 100644 2017/6a.plaintext create mode 100644 text_prettify.py diff --git a/2017/2017-challenge6.ipynb b/2017/2017-challenge6.ipynb index 1d353f1..bc0b90d 100644 --- a/2017/2017-challenge6.ipynb +++ b/2017/2017-challenge6.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "metadata": {}, "outputs": [], "source": [ @@ -15,6 +15,7 @@ "%matplotlib inline\n", "\n", "from cipherbreak import *\n", + "from text_prettify import *\n", "\n", "ca = open('6a.ciphertext').read()\n", "cb = open('6b.ciphertext').read()" @@ -23,31 +24,29 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ - "def tpack(text, width=100):\n", - " lines = [text[0]]\n", - " for word in text[1:]:\n", - " if len(lines[-1]) + 1 + len(word) <= width:\n", - " lines[-1] += (' ' + word)\n", - " else:\n", - " lines += [word]\n", - " return lines" + "# def tpack(text, width=100):\n", + "# lines = [text[0]]\n", + "# for word in text[1:]:\n", + "# if len(lines[-1]) + 1 + len(word) <= width:\n", + "# lines[-1] += (' ' + word)\n", + "# else:\n", + "# lines += [word]\n", + "# return lines" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "JDPWD JGLOF YBDQA LKYFD PPFTY OFKQY ICSHD QMIDK KYOES RQBYO FOKRJ DHYRB YPYKO YXTLS QRBYI LCDIQ RDRFL KRBFK HQBYJ DWBDT YEYYK HFOKD MMYOE SRRBY PYBDQ EYYKK LPDKQ LJOYJ DKODK ORBYP YFQKL RBFKA JSCBR LALLK BYPPL LJBDO EYYKP DKQDC HYODK OQBYI YZRKL JYQQD AYESR QLJYR BFKAR YIIQJ YQBYF QLHDK OUYQB LSIOJ LTYLK FRBFK HQBYJ DWBDT YMIDK KYORB FQJYD KUBFI YFBDT YRBYO LCSJY KRGLO FYUDK RYOZP LJILK OLKFO LKRHK LUBLU QBYHK YUESR RBYZF ZRBCB DMRYP UDQBF OOYKF KDCDT FRWFK DQRLK YIFKR YIFKQ LJYPY JDFKQ FKRBY YMBYQ SQPLL JDRRB YEPFR FQBJS QYSJF RUDQY KCPWM RYOSQ FKADK LRBYP MLIWD IMBDE YRFCC FMBYP FKTYK RYOFK RBYKF KYRYY KRBCY KRSPW FDQHY ORBYJ SQYSJ RLRYQ RFRDK ORBYO LCSJY KRFQD SRBYK RFCQL FASYQ QRBYF JMYPF DICFM BYPQC BLLIP YDIIW BDOJL TYOLK MYPBD MQFQB LSIOK RBDTY EYYKQ SPMPF QYODZ RYPRB YOFQC LTYPW DRELO PSJES RFRIY DTYQJ YULKO YPFKA UBDRY IQYRB YWOYT YILMY OLKYL OOZYD RSPYU DQDZP FYXYP SKKFK APLSK ORBPY YQFOY QLZRB YIFKR YICLK QFQRF KALZD QFKAI YPLUL ZEIDC HDKOU BFRYR FIYQR BDRRB YJSQY SJRBF KHUYP YDOOY OFKRB YPLJD KMYPF LORBY WPYDO FKQYN SYKCY UUEEU UUEUU UEUUU EUUUE UUUEU UUEUU UEUUU EUUUE UUUEU UUEUU UEUUU EUUUE UUUEU UUEUU UEUUU EUUUE EUUUE UUEUE UEUEU EUEUE UEUEU EUEUE UEUEU EUEUE UEUEU EUEUE UEUEU EUEUE UEUEU EUEUE UEUEU EUEUE UEUUE UUUEU EEEUE EEUEE EUEEE UEEEU EEEUE EEUEE EUEEE UEEEU EEEUE EEUEE EUEEE UEEEU EEEUE EEUEE EUEEE UEUUU EUUUE UUUEU UUEUU UEUUU EUUUE UUUEU UUEUU UEUUU EUUUE UUUEU UUEUU UEUUU EUUUE UUUEU UUEUU UEUUU EUUUE UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUEUU UEUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UEUUU EUUUU EUUUE EEUUU UUEEE UUUEU UUEUU UEUUU EUUUU EEEUU EUUUE UEEEU UUEEE EUUEE EUUUE EEUUE EEUEU UUEUU UUEUE UUEUU EUUUE UUUUU EUEUU EEUUE UUEUE UUUUE UUUEE UEEUE UUEUU EUUUU UEUUE UUUEU UUUEU UUEUU UEUUE UUUEU EUUUE UEUUU UUEUU UEUEU EUEUE UUUEU UUEUU UEUEU EUEUU EUUEU UUUUE UUUEU UEUUU UEUUE UUUEU UUEEE EEUEE EEUUE UUUUU EEEEE UEUEU EUEEE EEUUU EUUUE UUUEU EEEEU UEEEU UUEEE EUUUE UUUUE UUUEU UUEUU EUUUE UEUEU UUEUU UUUEU UUEUE UEUEU EUUUE UUUEU UUEUU UEUEU UUUUE UUUUU EUEUU UUEUU UUEUU EUUUE UUUEU UUEUE UUEUU UEUUU UEUUU EUEUU EEUEU UUEUU UEUUU EUUUE UEUUU UUEUU UUUEU UEUUU EUUUU EUUUE UUUEU UEUUU EUEUU UEUUU EEEUE UUUEU EUUUE UEUUU EUUEE EUUEU UUEUE UUUUU EEEEU UEUUU EUEEE UUEEE UEUUU EUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU EUUUE UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUUUU UUEUU UEUEU UUEUU UEUUU EUUUE UUUEU UUEUU UEUUU EUUUE UUUEU UUEUU UEUUU EUUUE UUUEU UUEUU UEUUU EUUUE UEUUU EUEUE UEUEU EUEUE UEUEU EUEUE UEUEU EUEUE UEUEU EUEUE UEUEU EUEUE UEUEU EUEUE UEUEU EUEUE UEUEU UUEUU EEEUE EEUEE EUEEE UEEEU EEEUE EEUEE EUEEE UEEEU EEEUE EEUEE EUEEE UEEEU EEEUE EEUEE EUEEE UUEUU UEUUE UUUEU UUEUU UEUUU EUUUE UUUEU UUEUU UEUUU EUUUE UUUEU UUEUU UEUUU EUUUE UUUEU UUEUU UEUUE UUFBD TYSQY OEZLP RBYEI DCHRF IYQDK OUZLP RBYUB FRYLK YQFRR LLHJY DUBFI YRLZF ASPYL SRRBD RRBYZ PFYXY FQQRY ADKLA PDMBW CLKCY DIFKA RBYHY WULPO ZLPRB YCFMB YPFKC BDMRY PZFTY UFRBL SRGLO FYFDJ KLRQS PYUBY PYRLA LKYVR RBYPY DPYLK IWRUL MLQQF EFIFR FYQDQ ZDPDQ FCDKQ YYESR FBDTY KLFOY DUBYP YLKYL ZRBYJ FQDKO DQZDP DQFCD KRYII KLLKY YIQYH KLUQY FRBYP QLFAS YQQFU FIIBY DOZLP LIWJM FDQYY WLSRB YPY\n" + "Lelqzq, C xnyhv Isxad en Gkcghhe ufc wbw gem ugejldv maw efjdexq. Rly zzh vwdr fwzhcff xbw LMXSR sjwqenauim gm e qakh agnwy ugemw zvimmh Mwkgoc leeamk u dnx ix msckd evgtx fgnocff jij sly ehwmamk wzztnwq en lgi Nwltfw nj Ujsigar. Xbss kund qy lhqy ln vylqmynd mn xqsg Bnhcw'r jladrx ss xbw Avclhwb Etwyml, ababl bsr e wgkpyusmif nj ujsizsbxm xqsg lgi Nwltfw. Isxad wuqr wbw jryo vi qgtpx xhkojd sol vlyjd xi yn ryps. Xbw bpow vem am xbw kswssmifr. Xbw emlks shw vem ss xbw Fvyss Tsjzqcv, sly kdgifc en lgi zgqx ix Peclaes ogmwz vem ttmfl evie sly jtmhk nj nzd Pcygxbgtwy ss Efwwehvqmu smh nzd xbaqh if Qlivdw, uenra lgi lmhrm ge xbw Bsfgrwok. Sly Cmmazs'w wsrxfw zx Vgcvoe vem ttmfl evie sly jdquamw ix sly Ezymgkioe zx Bskmwsqrukrym, zdrww sly “yqepw” semc nj amzvxamk nzd figj. Wi skp zaui wzztnwqw qwqi zgtrx ss xbw rmnw nj ifd sz lgi Mwuih Onrxwqw ix sly smgcwmx qgqpx. Lgi ifkc lwlecfhra dngulhshk zvy lgi Mlzxow nj Twtw ul Npseomu smh nzd Luffmhy Felvdrm ge Futxpif, zrx fn-shw gem smc cvde qzdvy lgi asqhyfr qcygx bsui vwdr, mg sly gmps hkeww vi wgtpx yn ryps mm Gkcghhe. Nzd gfmd en lgi yfc sz ugejldv zaui jghrnk rxlshkbl slyjd, wcfbi faflnamk, vmkp ufc suc zvy skp mqlfidr sz Rdym. Od wbgtpx td wuxd lyjd fyuzymw Isxad'w hwsaijj luk rihl gil ssxuujilk nr ng Kshvnr vq kesamk u dnra lqecd nj zgqkyv cswmlihlr vyndefamk nzd piuzxcgm sz ugejldv zaui. Nzzx vgtkbl tw yfnyaz smgw ss fgbenw zrx vdgchgil ugejldv maw. Ay zzh vwdr nzhreamk utnyn lgi ynnpolhsh ge xbw Hqjwqmud Bmjzdvm. Lzgcltw okdh vgsl nzd Zcydryjd ehv Aiumesll bmjzdvm ogmwz zvy hnpssktbsainab zyjrmifr sz lgi Wsdwuj rlcxs, ehv zx zaqwn od emktqyv slul bluhsil khb qgtpx td ihuqcjldh nzd wued auq. Vi qwqi udlsml qmazs. Qysmabaki Dgcmy'k trypoiwldh nskihl esl xnvawqc bsr kcndr gw zr cvde. C lgmhc vi gafln td evdd xi ltvh gtv yfdqcwr sh gmi ufnxbwq fs wwtfghxcff lyj fmzl, ayn A jrio gil utvlwmx zgbym ar jcytvcff sol vlyjd sh wzvnz sly kdzyfsl qgmhyj lmazs fy.\n" ] } ], @@ -55,989 +54,1505 @@ "print(ca)" ] }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "# def depunctuate_character(c):\n", + "# if c in string.ascii_uppercase:\n", + "# return 'UPPER'\n", + "# elif c in string.ascii_lowercase:\n", + "# return 'LOWER'\n", + "# else:\n", + "# return c\n", + "\n", + "# def depunctuate(text):\n", + "# return [depunctuate_character(c) for c in text]" + ] + }, { "cell_type": "code", "execution_count": 5, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ - "ca_text = '''\n", - "JDPWD JGLOF YBDQA LKYFD PPFTY OFKQY ICSHD QMIDK KYOES RQBYO FOKRJ DHYRB YPYKO YXTLS QRBYI \n", - "LCDIQ RDRFL KRBFK HQBYJ DWBDT YEYYK HFOKD MMYOE SRRBY PYBDQ EYYKK LPDKQ LJOYJ DKODK ORBYP \n", - "YFQKL RBFKA JSCBR LALLK BYPPL LJBDO EYYKP DKQDC HYODK OQBYI YZRKL JYQQD AYESR QLJYR BFKAR \n", - "YIIQJ YQBYF QLHDK OUYQB LSIOJ LTYLK FRBFK HQBYJ DWBDT YMIDK KYORB FQJYD KUBFI YFBDT YRBYO \n", - "LCSJY KRGLO FYUDK RYOZP LJILK OLKFO LKRHK LUBLU QBYHK YUESR RBYZF ZRBCB DMRYP UDQBF OOYKF \n", - "KDCDT FRWFK DQRLK YIFKR YIFKQ LJYPY JDFKQ FKRBY YMBYQ SQPLL JDRRB YEPFR FQBJS QYSJF RUDQY\n", - "KCPWM RYOSQ FKADK LRBYP MLIWD IMBDE YRFCC FMBYP FKTYK RYOFK RBYKF KYRYY KRBCY KRSPW FDQHY \n", - "ORBYJ SQYSJ RLRYQ RFRDK ORBYO LCSJY KRFQD SRBYK RFCQL FASYQ QRBYF JMYPF DICFM BYPQC BLLIP \n", - "YDIIW BDOJL TYOLK MYPBD MQFQB LSIOK RBDTY EYYKQ SPMPF QYODZ RYPRB YOFQC LTYPW DRELO PSJES \n", - "RFRIY DTYQJ YULKO YPFKA UBDRY IQYRB YWOYT YILMY OLKYL OOZYD RSPYU DQDZP FYXYP SKKFK APLSK \n", - "ORBPY YQFOY QLZRB YIFKR YICLK QFQRF KALZD QFKAI YPLUL ZEIDC HDKOU BFRYR FIYQR BDRRB YJSQY \n", - "SJRBF KHUYP YDOOY OFKRB YPLJD KMYPF LORBY WPYDO FKQYN SYKCY\n", - " FBD TYSQY OEZLP RBYEI DCHRF IYQDK OUZLP RBYUB FRYLK YQFRR LLHJY DUBFI YRLZF ASPYL SRRBD \n", - "RRBYZ PFYXY FQQRY ADKLA PDMBW CLKCY DIFKA RBYHY WULPO ZLPRB YCFMB YPFKC BDMRY PZFTY UFRBL \n", - "SRGLO FYFDJ KLRQS PYUBY PYRLA LKYVR RBYPY DPYLK IWRUL MLQQF EFIFR FYQDQ ZDPDQ FCDKQ YYESR \n", - "FBDTY KLFOY DUBYP YLKYL ZRBYJ FQDKO DQZDP DQFCD KRYII KLLKY YIQYH KLUQY FRBYP QLFAS YQQFU \n", - "FIIBY DOZLP LIWJM FDQYY WLSRB YPY\n", - "'''\n", - "sca_text = sanitise(ca_text)" + "# def repunctuate_character(letters, punctuation):\n", + "# if punctuation == 'UPPER':\n", + "# return next(letters).upper()\n", + "# elif punctuation == 'LOWER':\n", + "# return next(letters).lower()\n", + "# else:\n", + "# return punctuation\n", + "\n", + "# def repunctuate(text, punctuation):\n", + "# letters = iter(text)\n", + "# return cat(repunctuate_character(letters, p) for p in punctuation)" ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "(24, -1733.3180566179738)" + "('zeus', -1960.8847716972107)" ] }, - "execution_count": 6, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "key_a, score = caesar_break(sca_text)\n", - "key_a, score" + "ka, score = vigenere_frequency_break(ca)\n", + "ka, score" ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "lfryflinqhadfscnmahfrrhvaqhmsakeujfsokfmmaqgutsdaqhqmtlfjatdaramqazvnustdaknefkstfthnmtdhmjsdalfydfvagaamjhqmfooaqguttdaradfsgaammnrfmsnlqalfmqfmqtdarahsmntdhmcluedtncnnmdarrnnldfqgaamrfmsfejaqfmqsdakabtmnlassfcagutsnlatdhmctakkslasdahsnjfmqwasdnukqlnvanmhtdhmjsdalfydfvaokfmmaqtdhslafmwdhkahdfvatdaqneulamtinqhawfmtaqbrnlknmqnmhqnmtjmnwdnwsdajmawguttdabhbtdedfotarwfsdhqqamhmfefvhtyhmfstnmakhmtakhmsnlaralfhmshmtdaaodasusrnnlfttdagrhthsdlusaulhtwfsameryotaqushmcfmntdaronkyfkodfgatheehodarhmvamtaqhmtdamhmataamtdeamturyhfsjaqtdalusaultntasthtfmqtdaqneulamthsfutdamthesnhcuasstdahloarhfkehodarsednnkrafkkydfqlnvaqnmoardfoshsdnukqmtdfvagaamsurorhsaqfbtartdaqhsenvaryftgnqrulguthtkafvaslawnmqarhmcwdftaksatdayqavaknoaqnmanqqbafturawfsfbrhazarummhmcrnumqtdraashqasnbtdakhmtakenmshsthmcnbfshmckarnwnbgkfejfmqwdhtathkastdfttdalusaultdhmjwarafqqaqhmtdarnlfmoarhnqtdayrafqhmsapuameahdfvausaqgbnrtdagkfejthkasfmqwbnrtdawdhtanmashttnnjlafwdhkatnbhcuranuttdfttdabrhazahsstacfmncrfodyenmeafkhmctdajaywnrqbnrtdaehodarhmedfotarbhvawhtdnutinqhahflmntsurawdaratncnmaxttdarafranmkytwnonsshghkhthasfsbfrfshefmsaaguthdfvamnhqafwdaranmanbtdalhsfmqfsbfrfshefmtakkmnnmaaksajmnwsahtdarsnhcuasshwhkkdafqbnrnkylohfsaaynutdara\n" - ] + "data": { + "text/plain": [ + "\"Maryam, I found Jodie at Olympia and she has chapter six already. She had been leading the MIDAS operatives on a wild goose chase around Selcuk making a lot of noise about looking for the missing chapter at the Temple of Artemis. That gave me time to retrieve it from Jodie's friend at the British Museum, which has a collection of artefacts from the Temple. Jodie says she knew we would figure out where to go next. The clue was in the locations. The first one was at the Great Pyramid, the second at the fort of Qaitbay which was built from the ruins of the Lighthouse at Alexandria and the third on Rhodes, among the ruins of the Colossus. The Knight's castle at Bodrum was built from the remains of the Mausoleum at Halicarnassus, hence the “grave” task of guarding the book. So all five chapters were found at the site of one of the Seven Wonders of the ancient world. The only remaining locations are the Statue of Zeus at Olympia and the Hanging Gardens of Babylon, and no-one has any idea where the gardens might have been, so the only place we could go next is Olympia. The clue at the end of chapter five points straight there, since lighting, bull and oak are all symbols of Zeus. We should be safe here because Jodie's network has sent her attackers on to London by laying a long trail of forged documents revealing the location of chapter five. That bought us enough time to locate and decipher chapter six. We had been thinking about the evolution of the Imperial Ciphers. Tacitus used both the Vigenere and Beaufort ciphers which are polyalphabetic versions of the Caesar shift, and at first we assumed that chapter six would be encrypted the same way. We were almost right. Meanwhile Jodie's unexpected talent for forgery has given me an idea. I think we might be able to turn our enemies on one another by exploiting her gift, but I know her current focus is figuring out where on earth the seventh wonder might be.\"" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ - "print(caesar_decipher(sca_text, key_a))" + "pa = vigenere_decipher(sanitise(ca), ka)\n", + "repunctuate(pa, pua)" ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "((17, 21, True), -1723.2877779777489)" + "['Maryam, I found Jodie at Olympia and she has chapter six already. She had been leading the MIDAS',\n", + " 'operatives on a wild goose chase around Selcuk making a lot of noise about looking for the missing',\n", + " \"chapter at the Temple of Artemis. That gave me time to retrieve it from Jodie's friend at the\",\n", + " 'British Museum, which has a collection of artefacts from the Temple. Jodie says she knew we would',\n", + " 'figure out where to go next. The clue was in the locations. The first one was at the Great Pyramid,',\n", + " 'the second at the fort of Qaitbay which was built from the ruins of the Lighthouse at Alexandria and',\n", + " \"the third on Rhodes, among the ruins of the Colossus. The Knight's castle at Bodrum was built from\",\n", + " 'the remains of the Mausoleum at Halicarnassus, hence the “grave” task of guarding the book. So all',\n", + " 'five chapters were found at the site of one of the Seven Wonders of the ancient world. The only',\n", + " 'remaining locations are the Statue of Zeus at Olympia and the Hanging Gardens of Babylon, and no-one',\n", + " 'has any idea where the gardens might have been, so the only place we could go next is Olympia. The',\n", + " 'clue at the end of chapter five points straight there, since lighting, bull and oak are all symbols',\n", + " \"of Zeus. We should be safe here because Jodie's network has sent her attackers on to London by\",\n", + " 'laying a long trail of forged documents revealing the location of chapter five. That bought us',\n", + " 'enough time to locate and decipher chapter six. We had been thinking about the evolution of the',\n", + " 'Imperial Ciphers. Tacitus used both the Vigenere and Beaufort ciphers which are polyalphabetic',\n", + " 'versions of the Caesar shift, and at first we assumed that chapter six would be encrypted the same',\n", + " \"way. We were almost right. Meanwhile Jodie's unexpected talent for forgery has given me an idea. I\",\n", + " 'think we might be able to turn our enemies on one another by exploiting her gift, but I know her',\n", + " 'current focus is figuring out where on earth the seventh wonder might be.']" ] }, - "execution_count": 8, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "(m_a, a_a, o_a), score = affine_break(sca_text)\n", - "(m_a, a_a, o_a), score" + "tpack(repunctuate(pa, pua).split())" ] }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "gyotygparsneylhadnsyooscnrsdlnjbfmylxjyddnrvfilenrsrdigymnienondrnqcaflienjabyjliyisadiesdmlengyteycnvnndmsrdyxxnrvfiienoneylvnnddaoydlagrngydrydrienonsldaiesdhgfbeiahaadenooaageyrvnndoydlybmnrydrlenjnkidagnllyhnvfilagniesdhinjjlgnlenslamydrznleafjrgacnadsiesdmlengyteycnxjyddnrieslgnydzesjnseycnienrabfgndiparsnzydinrkoagjadradsradimdazeazlenmdnzvfiienkskiebeyxinozylesrrndsdybycsitsdyliadnjsdinjsdlagnongysdlsdiennxenlfloaagyiienvosislegflnfgsizylndbotxinrflsdhydaienoxajtyjxeyvnisbbsxenosdcndinrsdiendsdninndiebndifotsylmnriengflnfgiainlisiydrienrabfgndislyfiendisblashfnlliensgxnosyjbsxenolbeaajonyjjteyrgacnradxnoeyxlsleafjrdieycnvnndlfoxoslnrykinoienrslbacnotyivarofgvfisijnycnlgnzadrnosdhzeyinjlnientrncnjaxnradnarrknyifonzylykosnqnofddsdhoafdrieonnlsrnlakienjsdinjbadlslisdhakylsdhjnoazakvjybmydrzesinisjnlieyiiengflnfgiesdmznonyrrnrsdienoagydxnosarientonyrsdlnufndbnseycnflnrvkaoienvjybmisjnlydrzkaoienzesinadnlsiiaamgnyzesjniakshfonafiieyiienkosnqnsllinhydahoyxetbadbnyjsdhienmntzaorkaoienbsxenosdbeyxinokscnzsieafiparsnsygdailfonzenoniahadnwiienonyonadjtizaxallsvsjsisnlylkyoylsbydlnnvfiseycndasrnyzenonadnakiengslydrylkyoylsbydinjjdaadnnjlnmdazlnsienolashfnllszsjjenyrkaoajtgxsylnntafienon\n" + "Maryam, I found Jodie at Olympia and she has chapter six already. She had been leading the MIDAS\n", + "operatives on a wild goose chase around Selcuk making a lot of noise about looking for the missing\n", + "chapter at the Temple of Artemis. That gave me time to retrieve it from Jodie's friend at the\n", + "British Museum, which has a collection of artefacts from the Temple. Jodie says she knew we would\n", + "figure out where to go next. The clue was in the locations. The first one was at the Great Pyramid,\n", + "the second at the fort of Qaitbay which was built from the ruins of the Lighthouse at Alexandria and\n", + "the third on Rhodes, among the ruins of the Colossus. The Knight's castle at Bodrum was built from\n", + "the remains of the Mausoleum at Halicarnassus, hence the “grave” task of guarding the book. So all\n", + "five chapters were found at the site of one of the Seven Wonders of the ancient world. The only\n", + "remaining locations are the Statue of Zeus at Olympia and the Hanging Gardens of Babylon, and no-one\n", + "has any idea where the gardens might have been, so the only place we could go next is Olympia. The\n", + "clue at the end of chapter five points straight there, since lighting, bull and oak are all symbols\n", + "of Zeus. We should be safe here because Jodie's network has sent her attackers on to London by\n", + "laying a long trail of forged documents revealing the location of chapter five. That bought us\n", + "enough time to locate and decipher chapter six. We had been thinking about the evolution of the\n", + "Imperial Ciphers. Tacitus used both the Vigenere and Beaufort ciphers which are polyalphabetic\n", + "versions of the Caesar shift, and at first we assumed that chapter six would be encrypted the same\n", + "way. We were almost right. Meanwhile Jodie's unexpected talent for forgery has given me an idea. I\n", + "think we might be able to turn our enemies on one another by exploiting her gift, but I know her\n", + "current focus is figuring out where on earth the seventh wonder might be.\n" ] } ], "source": [ - "print(affine_decipher(sca_text, m_a, a_a, o_a))" + "lcat = '\\n'.join\n", + "print(lcat(tpack(repunctuate(pa, pua).split())))" ] }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'etoainhsrdlumwycfgpbvkxjqz'" + "1932" ] }, - "execution_count": 10, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "ltrs = [p[0] for p in english_counts.most_common()]\n", - "cat(ltrs)" + "open('6a.plaintext', 'w').write(lcat(tpack(repunctuate(pa, pua).split())))" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [], + "source": [ + "pub = depunctuate(cb)\n", + "scb = sanitise(cb)" ] }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 46, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'yrkfdlbqpoisjcumzaetwhxgvn'" + "('jcarykujniqadmv', -3289.3609056830232)" ] }, - "execution_count": 11, + "execution_count": 46, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "ctls = [p[0] for p in collections.Counter(sanitise(ca_text)).most_common()]\n", - "cat(ctls)" + "kbv, score = vigenere_frequency_break(scb)\n", + "kbv, score" ] }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 47, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'A': 'g',\n", - " 'B': 'h',\n", - " 'C': 'w',\n", - " 'D': 'i',\n", - " 'E': 'p',\n", - " 'F': 'a',\n", - " 'G': 'j',\n", - " 'H': 'k',\n", - " 'I': 'l',\n", - " 'J': 'm',\n", - " 'K': 'o',\n", - " 'L': 'n',\n", - " 'M': 'c',\n", - " 'N': 'z',\n", - " 'O': 'd',\n", - " 'P': 'r',\n", - " 'Q': 's',\n", - " 'R': 't',\n", - " 'S': 'u',\n", - " 'T': 'b',\n", - " 'U': 'y',\n", - " 'V': 'q',\n", - " 'W': 'v',\n", - " 'X': 'x',\n", - " 'Y': 'e',\n", - " 'Z': 'f'}" + "'Piuo tgnlqva rdn uggsvzeuvlr ed lurg nrubgg ve dyp kztmitehdd flrmqantm bvn enarvtu vd Zgvhrerir rez nttcgegm uy Tlxt lk unu tez la hbt dten, rm mgmggtz ld uog Axruglt. Ot ngrgtz bos orxg utttvyqg ael sn xgutz ybu yq Tlwwuvee uy lluo Enbpueba Gbaiufba yel Ptgrevoa Ntegmvk, zbu hot Uymn pgnt guettlba eem, ggerfkrydd ubg qlna sa tpt Fymtj ttxriltl s ntsgth, welpr sepe ul e atc dldrd mlwhrmgn atyx uog Lvdvo. Soyqisqd fbslmweh hl ggurgm bcn lmhhgm sotnbvh sa tpt Rmbvde rn r kygi ma fybgeut, uog Axruglt nsettm oie unu arht ln yuott tvmigrstm ugetgexn qfm, uy uog abgstcns ma nyxt, bg prn ewrfntm hgvoksord ttemgrhvlra. R nuebbs qrn ggtshtm yq bos Oteeut yr uot ynmsh la hot Gkstgyn, yav, urwte idq, Rhtcfkrr pen ngru ul dcis abvguqq ye ova hrwwqd gnueht pognt nu pra utrztm yq bos Uxsgglt’a lpe fvdmwfveen. Bin mtebo osn r ugvgvlbn avlek ul kt, rrz r srilaar tigeu hy rqq bcn zhvtrmn. Ih prn naqt sn r ttrd dlnn gptd zd ublng hl poye os qrn rlu fggnlryqpe jeype. Roxyttu, xkhtlvtg, yn uot fssarrfg rez hot youd wsnngn fekt ul bcn nmbng; rez ie sblxve tqrstn, erm pognthug jrlua ya urdqtfo pttt raatxydam, nwn eext cen le exq pwsn; rlg zim r nilhpu nloq lr btrgilh kb ova mteho gtpsveu ru hot rgpn lt hlfitu iu zoifjqq. Bouo ndksrhbd pra ceehtratm lq uot ccms-osggrm toxlbt boqv ot brm lgte ggelhum yq sliale lr bos Uxsgglt’a flxkyel. Nlxiuver qlnh ll twxt ie rfflvehceg vot exyihvlba Urpcnuibn Dofbqdin qo uog etc ulittllf ma ubt styivesa. Os qrn sortutm pibo mufbtveu hot atyhurt sgrfg cvuo Syqsnleir rrz otrzam tptgg ul syeagylu Esqhefba. Iu pra sepe uoge ubeu uog xlmo la hot Symtw cyn fuiteqtz. Arqbabvao pgyut yn ovn avlek ru hot rgpn vr y qsvutt ul Seul mebtl vot nvahb mrd laakht ubt jedtema sa Wsd vr uog qtrg yh unu flrnbdaovsa sa Wsgfon Rtttfvrin Ertxgen II rem Difucn Yetyion Olrsgqvbn. “Ct rtg twstanmrd fbrgugm yd yig wmnu kbeinvftrb rdn hggru Gkstgyn Mkyvuire hy ntfont Rsw Gyxrre ve uba Ekhuogge Wiehmyen qfm dgu dyo pgvha uk yt ln uog dlnn yh unu Flztw Ysfbqhsgay. Dlog qgemtg Eoguglqe ora eqgtetd rsvm hot ftvft yh nago r dlna, lbu vn kla nl eyu ggslitt bos Glmgw ygnlgt hvt rsnnieh yn uot qarf votr dlo krd yg ubfu uoeu dyo pvqd jluf ovk. Dlo htqq ka unsu vrutddvhtrmt zhlx e frfhbgtz usc obhutnha uorh bos vgriult Srqhembm prn hot Symtw elm uo xranvru ovn aisrmguggn ir uot Rsgtp. Poiqt hbt Yrtfrfwrea uogkntqvan qht brqvwgqd uy eriu xbso ln hot Fyttv, Grqurfoa vn rr amagrugm Gykre rrt os ybnh yt ahlssgt ysblgg ot see mtabgke uog ntsogvuq sa tpt Vksttirq fizoshn. Ubt Fyztw pixq xu gtsligttm, lt kla, elbt arkiqd rrt thugdyet qyb jeyw purq sed ubg sgvsa. Rdn nl hl ubg ntiglun trgh la hbt ugoa ntmgd ya Rutvfldy vd qovso ubg arug sa tpt eieub dthvyl rdn la hot Symtw ibnsra piqq ir uvxg ft fuiteqtz. Oeuvd bosf vu cvqd lt hbenmsn yd hot erfvtrb Yqzdqyever Hlmzanm ma Peg.'" ] }, - "execution_count": 12, + "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "trans = {pr[1].upper(): pr[0] for pr in zip(ltrs, ctls)}\n", - "trans" + "repunctuate(vigenere_decipher(sanitise(cb), kbv), pub)" ] }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 48, "metadata": {}, "outputs": [ { - "name": "stdout", + "data": { + "text/plain": [ + "('hnypjvriltvyzlt', -3351.460892110415)" + ] + }, + "execution_count": 48, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "kbb, score = beaufort_frequency_break(cb)\n", + "kbb, score" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'jdeksfkoiqfhtmesfgdmhdenubvlfhsyhekfreuihjmafmdfueiuunutiwmfmkdlhyxidsldtasdehuudgiumsfdxsufmensmcfavejffumnyekewfhshknsmfsfmaufkffbffsnskfyfgtfmekelhbfefsscbiffulhlbfefmnwfavmnadedhuenamfkhsxhfuxlsxldduxlhulkfsuudxlkguftdmaxeekfrnlmjfsfqfufsnxlhtnsfbhrphaivekfhollnydkftnmfcsechduflhlftsfeptojunuhvenhyfjimwhitnashmflysnafkfudtekgxaidthwtknnkdurensfrgtmkdllnrrfmgxskydenydkfhzxdihgmhbhsonytnxshrefkffbffsnslghsenkdbejfyhefnyndlfsmdkrshtfmrftgshilgumenekflwtgsdlenylnbfkfiilhjhrmfmesdxbflhimfsnshednulgmehexejhlfsfteenavekelfuhefnudlfnsmesnyekffbfgsnsaweehpfudihirsdtmihjhllfudfnidqezxdfeivntldlyhadivfleheekkfsfjfjhlefumenavekefbgfsnslmkugkvkdtdhulkdknfhekihlhrsdfqmyllknspenbfhumghhduywifqfueengjikdlxsdfumldeiilyfidhlhsfhiimmlfqftaveknlfemkknbkejhlunegfrmnuhihvpunjuuxabfslbmsfnqfsnydlfgngwihtfhumejgaxlvahllflthbefnkdljnxlfhumdthxaidsgihtflhulkkfsfpfspunelnxfhipfrljfsfhllecaifmjdluhbfjhkouhiihdglunsmdlildurhflnxinukeisdurmykdlmfhejtfwndsfheekfufimnsynrrfedezxdsqivekcllvbghekukhldussfhlfmavdlfjdmelgsfhmsxaoxsekgekfkhmafevsfbnpfmavgndlmvnuekefbgfsnslsobbhulmnbdedhuholeunddbfduhggmeueduqekfhbadecoxllhhxledxlixsyiixlglekfufjrmrfsunrnyekfgsnpeutfkejhltkhsrenjdekkftxsdurejgyshrcifgfhtfjcfkthiemnudhhumjghmfmdkfsfentntzsnueshirhtxlddkhlnuhvekfuekhdfkfinklnyekftnlgcjhlrfqfhifmlgjxledwljsnefnyjellknspheekfufimduhieeefsenthdomheflekfydyeklivafymsfekfphievmlnyahvduekfveisnyejftnulxiljeglnyahstxlhsseuduxlsifbfulddgvmixtcxlahfadxklnunsgexljfhsfedgsflkivtkhsrflbvnxsanlebxudycufuehtmrsfhefbfgsnsmmbdedhuenkgtxsffhcsnbhuhcvekfumsekfsupdtsmnblgumvfevnxitdefembfnyekfimmlnyejftnmfcntsyienswbvnxsifhlgshrsctnihkhlhhtfhmvfhdmekfgscufnylwtkhinllawfdyvnwmnunesftmrfseketnmfcafymtfekffhlldurnydlfvfhrekfuvnxbgwaflxrfekhevnxieiiwncukdbvnxeejibfejheduefiicsfutfxsnbhthgewtfmlgulxrrfleldlheekeeshdenstgjrhtxkkhlekftnlgchumclbhlldurjellxgfnsefsldudlfunsdkjkdifekebhsahrdhulekfbkgiqflgsfxuidpfhwenbhofbxtknyejgtnmfbthirhtxlcmhufmwthefmsnbgvhumkebxleaflemhgfmaeynsfkfthtnflesmvekflftxreevnydkfdbgfsdgjtdgkeslekftnmedjdiizfsftnqfsennsvnwvnxsyhbdhwhumfpfsvnufvnwqunjjciighvekfftdtfhtmlnenekfkgqfuejghsenyekefsxfldnsvnyhrscunihdtjkdtkekfxiefnydkfuduekiesdnuhtmnyekftnlgcdeleiyjdiidudebfafrfqfhifmxtfdiekeudejdiiaesxhsmemavekfhusefueagavinudhuqommflknyjhs'" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "beaufort_decipher(sanitise(cb), kbb)" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "('ryajcqgrnskaxof', -3289.3609056830232)" + ] + }, + "execution_count": 50, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "kbbv, score = beaufort_variant_frequency_break(cb)\n", + "kbbv, score" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'piuotgnlqvardnuggsvzeuvlredlurgnrubggvedypkztmitehddflrmqantmbvnenarvtuvdzgvhrerirreznttcgegmuytlxtlkunutezlahbtdtenrmmgmggtzlduogaxrugltotngrgtzbosorxgutttvyqgaelsnxgutzybuyqtlwwuveeuylluoenbpuebagbaiufbayelptgrevoantegmvkzbuhotuymnpgntguettlbaeemggerfkryddubgqlnasatptfymtjttxriltlsntsgthwelprsepeuleatcdldrdmlwhrmgnatyxuoglvdvosoyqisqdfbslmwehhlggurgmbcnlmhhgmsotnbvhsatptrmbvdernrkygimafybgeutuogaxrugltnsettmoieunuarhtlnyuotttvmigrstmugetgexnqfmuyuogabgstcnsmanyxtbgprnewrfntmhgvoksordttemgrhvlrarnuebbsqrnggtshtmyqbosoteeutyruotynmshlahotgkstgynyavurwteidqrhtcfkrrpenngruuldcisabvguqqyeovahrwwqdgnuehtpogntnuprautrztmyqbosuxsggltalpefvdmwfveenbinmteboosnrugvgvlbnavlekulktrrzrsrilaartigeuhyrqqbcnzhvtrmnihprnnaqtsnrttrddlnngptdzdublnghlpoyeosqrnrlufggnlryqpejeyperoxyttuxkhtlvtgynuotfssarrfgrezhotyoudwsnngnfektulbcnnmbngreziesblxvetqrstnermpognthugjrluayaurdqtfoptttraatxydamnwneextcenleexqpwsnrlgzimrnilhpunloqlrbtrgilhkbovamtehogtpsveuruhotrgpnlthlfituiuzoifjqqbouondksrhbdpraceehtratmlquotccmsosggrmtoxlbtboqvotbrmlgteggelhumyqslialelrbosuxsggltaflxkyelnlxiuverqlnhlltwxtierfflvehcegvotexyihvlbaurpcnuibndofbqdinqouogetculittllfmaubtstyivesaosqrnsortutmpibomufbtveuhotatyhurtsgrfgcvuosyqsnleirrrzotrzamtptggulsyeagyluesqhefbaiuprasepeuogeubeuuogxlmolahotsymtwcynfuiteqtzarqbabvaopgyutynovnavlekruhotrgpnvryqsvuttulseulmebtlvotnvahbmrdlaakhtubtjedtemasawsdvruogqtrgyhunuflrnbdaovsasawsgfonrtttfvrinertxgeniiremdifucnyetyionolrsgqvbnctrtgtwstanmrdfbrgugmydyigwmnukbeinvftrbrdnhggrugkstgynmkyvuirehyntfontrswgyxrreveubaekhuoggewiehmyenqfmdgudyopgvhaukytlnuogdlnnyhunuflztwysfbqhsgaydlogqgemtgeoguglqeoraeqgtetdrsvmhotftvftyhnagordlnalbuvnklanleyuggslittbosglmgwygnlgthvtrsnniehynuotqarfvotrdlokrdygubfuuoeudyopvqdjlufovkdlohtqqkaunsuvrutddvhtrmtzhlxefrfhbgtzuscobhutnhauorhbosvgriultsrqhembmprnhotsymtwelmuoxranvruovnaisrmguggniruotrsgtppoiqthbtyrtfrfwreauogkntqvanqhtbrqvwgqduyeriuxbsolnhotfyttvgrqurfoavnrramagrugmgykrerrtosybnhytahlssgtysblggotseemtabgkeuogntsogvuqsatptvksttirqfizoshnubtfyztwpixqxugtsligttmltklaelbtarkiqdrrtthugdyetqybjeywpurqsedubgsgvsardnnlhlubgntigluntrghlahbtugoantmgdyarutvfldyvdqovsoubgarugsatpteieubdthvylrdnlahotsymtwibnsrapiqqiruvxgftfuiteqtzoeuvdbosfvucvqdlthbenmsnydhoterfvtrbyqzdqyeverhlmzanmmapeg'" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "beaufort_variant_decipher(sanitise(cb), kbbv)" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'ytsfeqziozzjyzynifmpczahrmdxemcpjzkmjwjlxnnyonyerofpohxcddrcgzewuxdyioknuwxnbjvyqlnrzresxtfivjwqfyuewdiyowzlefdbxcvvjphzvvgclgtmtgqgsgouncvhzdhgqpoiaeutqtjvpqbodegstcrmcxrtdyybzkeywyeuuvsdtaoxbyrkleslsgczexwgbxntrmeysyaguvwjwqjgydepouomrjtzujwohgqvcmueioasbmdrqtsaviskmkxsekqbnteipeknauupiftymqkenkipdeaxaftxauudzckvvnjftnmtgbeehwbimsclcessglcireuhgwwlyxjfngmnmrebmmfkvpaohxxsgbvzoywwgzcuqnojzxpefrmkzpmgksvajuryrkimuzevnjlqwexpybstphbsiezbiqccknatjvowdxwkenfosfjjrfspkiojnaeaceignjpkmhmpswfczqbjhvppczhdvjtvlkwvgcecjedqrxtabnyivskgpgpbmityxuktwmmlrgqyvvawhlngwiahbktyzvqynncbbdqzdeeeoershbiqltegjriukialufyukgvtzekncmyafwndyamvtstwryacxyallqpaopcnwrsqtgzrgfpejoymndfxaazwdfhmmcgpwltsbxjvvoageyfazkzskfccocgmwucfjsnqzuevanhtxwxoaxdttlqrohnwjfhzghonqxscdddzywlzgedmnfspenyehypvtwlgugrxjxglrjrkvdvmievpftyuocdicijifknqwvqjblqlwowcrgkqbxrnihxzlqcwubpwbbdlyrxbldlhguqedueejcuvcgyxnyzwmviaiwexxagvfnvfisrlwglpldcjsibqqgvuienlufstzzhanbsnitujiyexvvzuxzsgcpzhwlbpztqxvcuzksmsvmckgsamvqislpmpebwztxycgdboztpckmeyncijrcuamgbamtujurczsifncmuykyvsobuykolymrgjrokaycaizhkkcpkiyykdkcokmoaxuoaslievdhtpnykwjqhctxhucldgakaqovdcppxhrcduwngahltatswfaebolamgzmlbrraeeaicgyvomorpeavueckyysketvfraqyxxzpdxziewwaazksgqexgakjwafruwhzkwoohwfyzaqjcebhhwzbcokqsxweviwgblgawlimoqbgbwljybjxiqvguxvkwaydleqxxczkkrjndjipnuckiensalufwzdbcvlzboiimqihhqgqligodxmetgvuyynjfueadtioypxvvtjananrwtwiwqecsfrafoecgmigjstastytaoaaaicbbqfwczwgazhlhqoywpapkdnijysxgwscchyyqvymiyhssfwliaonsfteylmqgdavsdgzeruprqimkbigpdzcijjgiapvrdsfillydvlkddcfgbrzusfbthejdltrhgpwfjdefhatrynubwqmgmbenqeauduywpadbqwcguysfrnxklcgmigjsbgnoqkgmhagmiyhqyvpkpulmnexfgruzehgcppkjquwegfxcvdymgtxfrdfjxdehtvqinowziyfadvepfjumnxnkgegwceptacydlungwxeqkikgyqqaghwclrniddelxibvghlrqdoqjnblmlpfuavvumalzqsiibaywlutzncqynnpllygpdiqrndrdtkxafowgexyztnhjoefbnkmqcyurmmlzpomoxzgzaycskbzxsglywehercavykijxmayepzokgrwrskcpkzifynzsmraaamwausemvnzmiftcmkgqeibgvzyuajgfkmcnhaausphtlsenhnfecpfczdmvgxzrepwdjnrzbcggfobytwrsbxcuuefyprmkdoqjreayfqyviakimlaqqaafzormkycourkqymvgivresfbfflondaypnqurwdwtyoadrbctnsirqkzerxegpteaniovvkfriypvlkedyziaaejijgiguwldnbdlngbdofzpbzcbufvtfonjytalwrkvpxwlbvyquadgdzzsauoaohxxfceuxnaqaumnpryjsmkdiyqumafndewkdhypzatgntredpgiyiuhvalamveqvsgdknfqxkdzvrhxfxcubicgmrqhwuiswmlzbhzzeylhnqgp'" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vbai = vigenere_decipher(sanitise(cb), 'arcanaimperii')\n", + "vbai" + ] + }, + { + "cell_type": "code", + "execution_count": 53, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'ybwfeqpgshhzozgrifmfadiphcdfimcpzxourmzlfrnyodwizwvfopbcddhakhmmkxlciokdsafvrzvgulnrppiafjvidnwqfosielyooedleftzbkdlzppdvvgsjkbujwqowgoudazphtxgytoiausxybzlpyfodewqxkzcsxzxdyyrxomgmoecyvsdjysfjohktislswadmfmwbfrtrmuwwgiwkvenwqjwwhmxekouvjtzkhawpwgvkqueieywjuthqbwaviiiqsfiukyfnteynisvqkuxmftycoomvaypliaxavrbicktzkovvnzdxvujwbmihwbykwktsusaklcihcypommlgbjfnwkruzurmujkvpqmlffiwbddoywmedkcgdordxpevpqshfcgswvajkpczsycuhivnjboamffobaxphbigihjygckonatztselnmkmrfosvhnznifkqsjnauygmqwdjxomhmfqankpgbrlvppsxlldzjvtowvgscgrmtgrfxabnogzaswfgxfmitovysbmcmtvgqylteepbdgemahbarchdgonvgbbdgxhmmueezwhbigjxmozhicoialkdccswlthiknccwenedtyiqvtsjuvgisnyiplqpqmtkvmhsyxgzrwdtmreomvhfxaqxalnxcmkkpwljqffrlloikeyfqxohaavckscgmmsgnridqhyevadfxfeneafhttlgpspvmzfpdghodobakttdhcwlzwchuvvipmryehonzbebwuovxjxwjvrzalddqievfdxgcesdqgijiviryelgjjpqlweugzoagbfvnihnxpykmkbxabbdbwvfjbtlpkuqetsimrskvkkyxnoxaudyqieixxawtjvdvyszpwglfjhkriybyugvuycrtcvithdhanrqrqbkzigixvvpsbhawsphlwlbfxxyflsuhosmslkgsoiqmduislfktmjmptfccgdrmdbxsammcncizpgcicwbiqtujkpghayvnkquykotwwjkokwpymrwhvwsqocimzhkaatsqooklocokcmefceqstmevdxrtvgamjylctxxsgtlwqkiuovdsntfphsdcangaxjxibimfiibolqkkhubrrzeeeayakgdecozteavkcgsgoikmxvfrqocffpfdfdiewmyehsiwqmbgakzuenzkmhhowooxujghqgjkibhhmxfkwagsfaevimeftoqmlqqoqbwzatrorjfmqvgkvzseqodtiqxxsxoszzddrmpnusimmviqlcjwzdrazthreiqqqihxokytywolbmetwtyggdzfciadtymcxflltrenanhuxeqmgekwfravmikocygrwtasjwxiwqqaqgbbqvughewqzpphqooutixatnqnysxwuwkkxoyyzymiofwanmbiisnsfjcctugwdizsdgpcvcxhgiuobigfbdkqzzgqepvrtqjqtboddpkddsdkjzpksnfthezbpbzxwpejjdevfebzodujaqmgczivyuqulyywpqbfyeswugwfrnnipkocygrwbgneooouxqgumyhqottsxkbmvixfghsdmpwspxojqumcknfsldgqgtxvphnrntepxvqidmahqovalzepfzsqvfdagmkwcefrekgtbuvkwxegimsoogqikhwcbprqltulfmbvgxjvylegjvflmlfdyidlkmipzqsygfigmbubdncqolrxtbogxhiqrdbvlbananswgenwdbvxzomjbnkcoggchcmtdpomevdohqocaobzxiepgeuxezgavyagnfuqoexdokghuvassfkhmfynpqqziqqmeeusectrhuyvtkqkgqugfodpouingfkcarpiqksxltlsullvnuspngzdmlebhzufwlnnrzrakonerybarsbnaycmvopzqkdoghvmiovqgziakykpiygqandormawgwchaqgqvgilpianrvftsndaonrychmdexyoatpfkbdiizukzehvioxjuavmovvadvqgfllsidyzyyemryzgqkuwltlfltdwblsfzprxgjcvltnsnjyjypezalpfalbvooyilwtzhwauoqmlffvsecbnaqqsqvxhojaqkdiooyuivddmakdhondibwdtzidpgywmcplqliqveqlqklsdvqfodzvhfbnfskbqggmrgfacqimmtdbhzpcctpdggx'" + ] + }, + "execution_count": 53, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "vbai = beaufort_variant_decipher(sanitise(cb), 'arcanaimperii')\n", + "vbai" + ] + }, + { + "cell_type": "code", + "execution_count": 54, + "metadata": {}, + "outputs": [ + { + "name": "stderr", "output_type": "stream", "text": [ - "mirvi mjnda ehisg noeai rrabe daose lwuki sclio oedpu tshed adotm iketh ereod exbnu sthel nwils titan othao kshem ivhib epeeo kadoi ccedp utthe rehis peeoo nrios nmdem iodio dther eason thaog muwht ngnno herrn nmhid peeor iosiw kedio dshel efton messi geput snmet haogt ellsm eshea snkio dyesh nuldm nbeno athao kshem ivhib eclio oedth asmei oyhal eahib ethed nwume otjnd aeyio tedfr nmlno dnoad notko nyhny sheko eyput thefa fthwh icter yisha ddeoa oiwib atvao istno elaot elaos nmere miaos aothe eches usrnn mitth eprat ashmu seuma tyise owrvc tedus aogio nther cnlvi lchip etaww acher aobeo tedao theoa oetee othwe oturv aiske dthem useum tntes tatio dthed nwume otasi utheo tawsn agues sthea mcera ilwac hersw hnnlr eillv hidmn bedno cerhi csash nuldo thibe peeos urcra sedif terth edasw nberv itpnd rumpu tatle ibesm eynod eraog yhite lseth evdeb elnce dnoen ddfei turey isifr aexer uooao grnuo dthre esade snfth elaot elwno sasta ognfi saogl ernyn fpliw kiody hatet alest hitth emuse umtha okyer eidde daoth ernmi ocera ndthe vreid aosez ueowe yyppy yypyy ypyyy pyyyp yyypy yypyy ypyyy pyyyp yyypy yypyy ypyyy pyyyp yyypy yypyy ypyyy pyyyp pyyyp yypyp ypypy pypyp ypypy pypyp ypypy pypyp ypypy pypyp ypypy pypyp ypypy pypyp ypypy pypyp ypyyp yyypy pppyp ppypp pyppp ypppy pppyp ppypp pyppp ypppy pppyp ppypp pyppp ypppy pppyp ppypp pyppp ypyyy pyyyp yyypy yypyy ypyyy pyyyp yyypy yypyy ypyyy pyyyp yyypy yypyy ypyyy pyyyp yyypy yypyy ypyyy pyyyp yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yypyy ypyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy ypyyy pyyyy pyyyp ppyyy yyppp yyypy yypyy ypyyy pyyyy pppyy pyyyp ypppy yyppp pyypp pyyyp ppyyp ppypy yypyy yypyp yypyy pyyyp yyyyy pypyy ppyyp yypyp yyyyp yyypp yppyp yypyy pyyyy ypyyp yyypy yyypy yypyy ypyyp yyypy pyyyp ypyyy yypyy ypypy pypyp yyypy yypyy ypypy pypyy pyypy yyyyp yyypy ypyyy ypyyp yyypy yyppp ppypp ppyyp yyyyy ppppp ypypy pyppp ppyyy pyyyp yyypy ppppy ypppy yyppp pyyyp yyyyp yyypy yypyy pyyyp ypypy yypyy yyypy yypyp ypypy pyyyp yyypy yypyy ypypy yyyyp yyyyy pypyy yypyy yypyy pyyyp yyypy yypyp yypyy ypyyy ypyyy pypyy ppypy yypyy ypyyy pyyyp ypyyy yypyy yyypy ypyyy pyyyy pyyyp yyypy ypyyy pypyy ypyyy pppyp yyypy pyyyp ypyyy pyypp pyypy yypyp yyyyy ppppy ypyyy pyppp yyppp ypyyy pyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy pyyyp yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yyyyy yypyy ypypy yypyy ypyyy pyyyp yyypy yypyy ypyyy pyyyp yyypy yypyy ypyyy pyyyp yyypy yypyy ypyyy pyyyp ypyyy pypyp ypypy pypyp ypypy pypyp ypypy pypyp ypypy pypyp ypypy pypyp ypypy pypyp ypypy pypyp ypypy yypyy pppyp ppypp pyppp ypppy pppyp ppypp pyppp ypppy pppyp ppypp pyppp ypppy pppyp ppypp pyppp yypyy ypyyp yyypy yypyy ypyyy pyyyp yyypy yypyy ypyyy pyyyp yyypy yypyy ypyyy pyyyp yyypy yypyy ypyyp yyahi beuse dpfnr thepl iwkta lesio dyfnr theyh ateno esatt nnkme iyhal etnfa guren utthi tthef raexe asste giong richv wnowe ilaog theke vynrd fnrth ewach eraow hicte rfabe yathn utjnd aeaim ontsu reyhe retng noeqt there ireno lvtyn cnssa palat aesis firis awios eeput ahibe onade iyher enoen fthem asiod isfir isawi otell onnoe elsek onyse ather snagu essay allhe idfnr nlvmc aisee vnuth ere\n" + "/usr/local/lib/python3.5/dist-packages/matplotlib/figure.py:403: 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": "iVBORw0KGgoAAAANSUhEUgAAAbAAAAEmCAYAAAADccV0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFFlJREFUeJzt3X2QZXV95/H3Jww+oIkItAQBbYyUWULWRUcWl2TLBU1Q\nMbC1xMVogCypWVdczYMxEDeLZWkVrta6/LFxMyoBNyyCRAMbNUoNGHwCnRlAZkBklgeZKR7aJyJS\nEUe++8c9VF2GgXv6PtD9636/qrr6nHPP7/6+ffr0/dzfOeeeTlUhSVJrfm6pC5AkaRwGmCSpSQaY\nJKlJBpgkqUkGmCSpSQaYJKlJBpgkqUkGmCSpSQaYJKlJBpgkqUlrlroAgP3226/m5+eXugxJ0jKw\nadOm71bV3Kj1lkWAzc/Ps3HjxqUuQ5K0DCS5s896HkKUJDXJAJMkNckAkyQ1yQCTJDXJAJMkNckA\nkyQ1yQCTJDXJAJMkNckAkyQ1yQCTJDVp5K2kkpwHHA/cV1WH7/LYHwMfBOaq6rtJApwLvAZ4EDit\nqjZPv2zN0vyZn+m97h3nvHaGlUjS4+szAjsfOG7XhUkOBn4D+M7Q4lcDh3Zf64APT16iJEmPNTLA\nqupq4Pu7eehDwDuBGlp2AvDxGrgG2DvJAVOpVJKkIWOdA0tyArCjqm7Y5aEDgbuG5rd3y3b3HOuS\nbEyycWFhYZwyJEmr2KIDLMlewJ8B/3WSjqtqfVWtraq1c3Mj/+2LJEmPMs7/A/sl4BDghsE1GxwE\nbE5yJLADOHho3YO6ZZIkTdWiR2BVdWNVPaeq5qtqnsFhwpdU1T3A5cApGTgKuL+q7p5uyZIk9Qiw\nJBcBXwNelGR7ktOfYPXPArcB24CPAG+ZSpWSJO1i5CHEqnrDiMfnh6YLOG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iRvmmG/Qxvi4eH5h9m9N/hk70dn+z9/8eLWbmqvp3kJcBrgPcm\n2VBV75lNaezk0ada+r6GfBI4CfhF4OJRK1fVT5PcDpwGfBX4JvBvgBcCN/fob18GI+09uxr7btOP\ndn3+IoPRdi9JTgOeD7x1xKoztZJHYM9i8M7nwSS/zGCI3tfzkry8m/4d4Ms92lwJ/HaSfQGS7NOj\nzdXAiUmenuTngdf1rG8DcFKS5zzSV5Ln92y7WF8BXtcdX38mcPyM+lkqDwH/Fjglye8sdTFT9CUG\n+9ZeSZ7B4Gfs804eFr//j7sfjyXJc4EHq+qvgQ8AL+nZ9EcMDoMvxr0MRlP7Jnkq/ff/ixncQu8k\nBmHWx5cYHKK8upt+M4NRUZ83EH8J/DlwIfD+nv0BfBo4jsGpgs/3aZDkpV2db+qOKCyZFTsCA/4e\neHOSmxnc6X4xhyhuAc5Ich6Dd+UfHtWgqrYmeR/wD0l+xuCcymkj2mxOcjFwA3Afg3tIjlRVNyX5\nL8AXMrhq66fAGcCdfdovRlV9I8nlDN4R3svg8M2yOmSzi0WPFqrqx0mOB65I8kBVNX/fzm7fOp/B\nuRSAj3aHtvpY1P4/7n48gV8FPpDkYQb7/n/q06iqvtddOLMF+FxV/UmPNj9N8h4G23EH8K2efW3t\nwnxHVd3dpw2D0HoX8LVun/wnerzpSHIK8NOq+j8ZXMz11STHVNWVPep8qLsI44dV9bOedb4V2Ae4\nKgkMbur7+z3bTpV34tBISZ5ZVQ90V6NdDayrqs1LXdeuutHv5qqa1Wh0xUsyD/xdVY28iu0JnuPd\nDC5w+eCUytKMdG+ANwO/XVW3LnU9i7WSDyFqetZ3F4tsBv5mmYbXcxmc+PZFU+ohyWEMrhjd0GJ4\ngSMwSVKjHIFJkppkgEmSmmSASZKaZIBJkppkgEmSmmSASZKa9P8BKMjCPkhDtbQAAAAASUVORK5C\nYII=\n", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ - "tt = ''.maketrans(trans)\n", - "print(ca.translate(tt))" + "fc = collections.Counter(sanitise(cb))\n", + "plot_frequency_histogram(fc)" ] }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 55, "metadata": {}, "outputs": [ { - "name": "stdout", + "name": "stderr", "output_type": "stream", "text": [ - "maryam jodie has gone i arrived in selcuk as planned but she didnt make the rendezvous the local\n", - "station think she may have been kidnapped but there has been no ransom demand and there is nothing\n", - "much to go on her room had been ransacked and she left no message but something tells me she is ok\n", - "and we should move on i think she may have planned this meanwhile i have the document jodie wanted\n", - "from london i dont know how she knew but the fifth chapter was hidden in a cavity in a stone lintel\n", - "in some remains in the ephesus room at the british museum it was encrypted using another poly\n", - "alphabetic cipher invented in the nineteenth century i asked the museum to test it and the document\n", - "is authentic so i guess the imperial cipher school really had moved on perhaps i shouldnt have been\n", - "surprised after the discovery at bodrum but it leaves me wondering what else they developed one odd\n", - "feature was a frieze running round three sides of the lintel consisting of a single row of\n", - "blackandwhite tiles that the museum think were added in the roman period they read in sequence\n", - "wwbbwwwbwwwbwwwbwwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb www bbw\n", - "wwbw wbwbwbwbwbwbwbwbwbw bwbwbwbwbwbwbwbwbwbw bwbwbwbwbwbwbwbwbwbw bwbwbwbwbwbwbwbwbwwb www\n", - "bwbbbwbbbwbbbwbbbwb bbwbbbwbbbwbbbwbbbwb bbwbbbwbbbwbbbwbbbwb bbwbbbwbbbwbbbwbbbwb wwwb wwwb wwwb\n", - "wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb www\n", - "www www www www www www www www www www www www www www www www www www www www www www www www wwbw\n", - "wwbw www www www www www www www www www www www www www www www www www www www www www www www www\n", - "www wwwb wwwb www wb wwwb bbw wwww bbb wwwb wwwb wwwb www bw www bbb wwbw wwbw bbb www bbbb\n", - "wwbbbwwwbbbwwbbbwb www bwwwwbwbwwbwwbwwwbww www bwbwwbbwwbwwbwbwwwwb www bbw bbw\n", - "bwwbwwbwwwwwbwwbwwwb www wb www bwwwbwwbwwwbwbwwwbwb www wwbwwwbwbwbwbwbwwwb www bwwwbwbwbwbwwbwwbww\n", - "www bwwwbwwbwwwwbwwbwwwb www bbb bbw bbbb wwbw wwww bbb bbw bwbwbwbbbbbwwwbwwwbw wwbw bbbb ww bbb\n", - "www bbbb wwwb www wb www bwwwbwwbwwwbwbwbwwwb www wwbwwwbwbwbwbwbwwwb wwwb wwwb www bwb www wwbw\n", - "wwww bwbwwwwbwwwwbwwbwwwb www bwwwbwbwwbwwwbwwwwb www bwbwwbbwbwwwbwwwb wwwb www bwb www wwbw www wb\n", - "wwbw wwbw www bwwwbwwwbwwbwwwbwb wwwb www bbb wbwwwbwbwwwbwbwwwbww bbb wwbw wwbw bww www bbbb wwbw\n", - "wwbwbbbwwbbbwbwwwbww www www www www www www www www www www www www www www www www www www www www\n", - "www www www www www wwbw wwbw www www www www www www www www www www www www www www www www www\n", - "www www www www www www www www wbwwwbwbwwwbwwwbwwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb\n", - "wwwb wwwb wwwb wwwb wwwb wwwb www bwb www bwbwbwbwbwbwbwbwbwb wbwbwbwbwbwbwbwbwbwb\n", - "wbwbwbwbwbwbwbwbwbwb wbwbwbwbwbwbwbwbwbwb www bwwbbbwbbbwbbbwbbbwb bbw bbb wbbbwbbbwbbbwbbbwb bbw\n", - "bbb wbbbwbbbwbbbwbbbwb bbwbbbwbbbwwbwwwbwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb\n", - "wwwb wwwb wwwb www bwwwbwwwbwwwbwwbwwi have used b for the black tiles and w for the white ones it\n", - "took me a while to figure out that the frieze is steganography concealing the keyword for the cipher\n", - "in chapter five without jodie i am not sure where to go next there are only two possibilities as far\n", - "as i can see but i have no idea where one of them is and as far as i can tell no one else knows\n", - "either so i guess i will head for olympia see you there\n" + "/usr/local/lib/python3.5/dist-packages/matplotlib/figure.py:403: 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": "iVBORw0KGgoAAAANSUhEUgAAAbAAAAEmCAYAAAADccV0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEcVJREFUeJzt3X2sZHV9x/H3R6A+gIrAFRHBq3bTFmsEXClWTVDUImrA\nFKmPoNGsVojaignUGgmRBKut0aRSUQlYUcEqQis+kMUKqFR2edwFka1AYYOAaBEkKg/f/jFn01me\n5sy9M3vv7973K5nMOWfOb37fe+6585nfmTPnpqqQJKk1j1roAiRJmgsDTJLUJANMktQkA0yS1CQD\nTJLUJANMktQkA0yS1CQDTJLUJANMktQkA0yS1KStF7oAgJ122qlmZ2cXugxJ0iKwdu3aX1TVzKj1\nFkWAzc7OsmbNmoUuQ5K0CCS5oc96HkKUJDXJAJMkNckAkyQ1yQCTJDXJAJMkNckAkyQ1yQCTJDXJ\nAJMkNckAkyQ1yQCTJDVpUVxKSpImbfbob/Ze9/oTXjXFSjQtjsAkSU0ywCRJTTLAJElNMsAkSU0y\nwCRJTTLAJElNMsAkSU0ywCRJTTLAJElNMsAkSU0ywCRJTTLAJElNMsAkSU0ywCRJTTLAJElNMsAk\nSU0ywCRJTRoZYEl2S/K9JFclWZ/kvd3yHZKcm+Ta7v5J3fIk+VSSDUmuSLL3tH8ISdLy02cEdi/w\n/qraA9gXOCLJHsDRwOqqWgGs7uYBXgms6G6rgBMnXrUkadkbGWBVdXNVXdJN3wlcDewKHASc2q12\nKnBwN30Q8IUauAjYPskuE69ckrSsjfUZWJJZYC/gv4Cdq+rm7qGfAzt307sCNw41u6lbJknSxPQO\nsCTbAV8D3ldVvx5+rKoKqHE6TrIqyZoka2677bZxmkqS1C/AkmzDILxOq6qvd4tv2XRosLu/tVu+\nEdhtqPnTumWbqaqTqmplVa2cm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ePhb12xLykAAAAASUVORK5CYII=\n", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ - "trans = {\n", - " 'A': 'g',\n", - " 'B': 'h',\n", - " 'C': 'c',\n", - " 'D': 'a',\n", - " 'E': 'b',\n", - " 'F': 'i',\n", - " 'G': 'j',\n", - " 'H': 'k',\n", - " 'I': 'l',\n", - " 'J': 'm',\n", - " 'K': 'n',\n", - " 'L': 'o',\n", - " 'M': 'p',\n", - " 'N': 'q',\n", - " 'O': 'd',\n", - " 'P': 'r',\n", - " 'Q': 's',\n", - " 'R': 't',\n", - " 'S': 'u',\n", - " 'T': 'v',\n", - " 'U': 'w',\n", - " 'V': 'x',\n", - " 'W': 'y',\n", - " 'X': 'z',\n", - " 'Y': 'e',\n", - " 'Z': 'f'}\n", - "\n", - "tt = ''.maketrans(trans)\n", - "print('\\n'.join(tpack(segment(sanitise(ca.translate(tt))))))" + "fp = collections.Counter(vigenere_decipher(sanitise(cb), kbv))\n", + "plot_frequency_histogram(fp)" ] }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 56, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.5/dist-packages/matplotlib/figure.py:403: 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": "iVBORw0KGgoAAAANSUhEUgAAAbAAAAEmCAYAAAADccV0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAElhJREFUeJzt3XmwJWV9xvHvIwORRWW7IquDkdIQLQOOBIKmDGgKt0Aq\naFwZLayJEYNLMEKMBUVpFUQrxlQlxhGIYyQK4gJxpwYQcEFnBpAZRmTCIlAsoxEViALyyx+nSS7D\nwDn3LNz73vv9VJ263X36Pe/v9vQ9z3n7dPekqpAkqTWPm+0CJEkahgEmSWqSASZJapIBJklqkgEm\nSWqSASZJapIBJ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L': 'o',\n", - " 'M': 'p',\n", - " 'N': 'q',\n", - " 'O': 'd',\n", - " 'P': 'r',\n", - " 'Q': 's',\n", - " 'R': 't',\n", - " 'S': 'u',\n", - " 'T': 'v',\n", - " 'U': 'w',\n", - " 'V': 'x',\n", - " 'W': 'y',\n", - " 'X': 'z',\n", - " 'Y': 'e',\n", - " 'Z': 'f'}" + "" ] }, - "execution_count": 15, "metadata": {}, - "output_type": "execute_result" + "output_type": "display_data" } ], "source": [ - "trans" + "fp = collections.Counter(vbai)\n", + "plot_frequency_histogram(fp)" ] }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 57, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.5/dist-packages/matplotlib/figure.py:403: 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": "iVBORw0KGgoAAAANSUhEUgAAAbMAAAEmCAYAAADoRn53AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFi1JREFUeJzt3X2QXfV93/H3JxJgwDbEIE/KkxcX0hbixg9COI3tphCI\nXGIrnYgiExfokFHcWOM2KWnlcYOpas9AnInbmdDWSiAhYBcIrRO1yCEupDHGGEs8I7BsGbARzsTi\nISSYwSD49o9zZF82K+3Z1V2tftL7NbOj8/D77fneo7P3c3/nnntuqgpJklr2Q/NdgCRJu8swkyQ1\nzzCTJDXPMJMkNc8wkyQ1zzCTJDXPMJMkNc8wkyQ1zzCTJDXPMJMkNW/hfBcw2ZFHHlkTExPzXYYk\naS9w5513PlFVi6Zrt9eF2cTEBBs3bpzvMiRJe4Ek3xzSztOMkqTmGWaSpOYZZpKk5hlmkqTmGWaS\npOYZZpKk5hlmkqTmGWaSpOYNCrMkS5NsTrIlyeop1r8ryV1JtidZPrL8zUluT7IpyX1Jzhln8ZIk\nwYAwS7IAuBx4N3AS8L4kJ01q9i3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\n", - " 'g': 'A',\n", - " 'h': 'B',\n", - " 'i': 'F',\n", - " 'j': 'G',\n", - " 'k': 'H',\n", - " 'l': 'I',\n", - " 'm': 'J',\n", - " 'n': 'K',\n", - " 'o': 'L',\n", - " 'p': 'M',\n", - " 'q': 'N',\n", - " 'r': 'P',\n", - " 's': 'Q',\n", - " 't': 'R',\n", - " 'u': 'S',\n", - " 'v': 'T',\n", - " 'w': 'U',\n", - " 'x': 'V',\n", - " 'y': 'W',\n", - " 'z': 'X'}" + "" ] }, - "execution_count": 16, "metadata": {}, - "output_type": "execute_result" + "output_type": "display_data" } ], "source": [ - "{v: k for k, v in trans.items()}" + "plot_frequency_histogram({k: 10**Pl[k] for k in Pl})" ] }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 91, "metadata": {}, "outputs": [ { - "name": "stdout", + "name": "stderr", "output_type": "stream", "text": [ - "maryam jodie has gone i arrived in selcuk as planned but she didnt make the rendezvous the local\n", - "station think she may have been kidnapped but there has been no ransom demand and there is nothing\n", - "much to go on her room had been ransacked and she left no message but something tells me she is ok\n", - "and we should move on i think she may have planned this meanwhile i have the document jodie wanted\n", - "from london i dont know how she knew but the fifth chapter was hidden in a cavity in a stone lintel\n", - "in some remains in the ephesus room at the british museum it was encrypted using another poly\n", - "alphabetic cipher invented in the nineteenth century i asked the museum to test it and the document\n", - "is authentic so i guess the imperial cipher school really had moved on perhaps i shouldnt have been\n", - "surprised after the discovery at bodrum but it leaves me wondering what else they developed one odd\n", - "feature was a frieze running round three sides of the lintel consisting of a single row of\n", - "blackandwhite tiles that the museum think were added in the roman period they read in sequence\n", - "wwbbwwwbwwwbwwwbwwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb www bbw\n", - "wwbw wbwbwbwbwbwbwbwbwbw bwbwbwbwbwbwbwbwbwbw bwbwbwbwbwbwbwbwbwbw bwbwbwbwbwbwbwbwbwwb www\n", - "bwbbbwbbbwbbbwbbbwb bbwbbbwbbbwbbbwbbbwb bbwbbbwbbbwbbbwbbbwb bbwbbbwbbbwbbbwbbbwb wwwb wwwb wwwb\n", - "wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb www\n", - "www www www www www www www www www www www www www www www www www www www www www www www www wwbw\n", - "wwbw www www www www www www www www www www www www www www www www www www www www www www www www\n", - "www wwwb wwwb www wb wwwb bbw wwww bbb wwwb wwwb wwwb www bw www bbb wwbw wwbw bbb www bbbb\n", - "wwbbbwwwbbbwwbbbwb www bwwwwbwbwwbwwbwwwbww www bwbwwbbwwbwwbwbwwwwb www bbw bbw\n", - "bwwbwwbwwwwwbwwbwwwb www wb www bwwwbwwbwwwbwbwwwbwb www wwbwwwbwbwbwbwbwwwb www bwwwbwbwbwbwwbwwbww\n", - "www bwwwbwwbwwwwbwwbwwwb www bbb bbw bbbb wwbw wwww bbb bbw bwbwbwbbbbbwwwbwwwbw wwbw bbbb ww bbb\n", - "www bbbb wwwb www wb www bwwwbwwbwwwbwbwbwwwb www wwbwwwbwbwbwbwbwwwb wwwb wwwb www bwb www wwbw\n", - "wwww bwbwwwwbwwwwbwwbwwwb www bwwwbwbwwbwwwbwwwwb www bwbwwbbwbwwwbwwwb wwwb www bwb www wwbw www wb\n", - "wwbw wwbw www bwwwbwwwbwwbwwwbwb wwwb www bbb wbwwwbwbwwwbwbwwwbww bbb wwbw wwbw bww www bbbb wwbw\n", - "wwbwbbbwwbbbwbwwwbww www www www www www www www www www www www www www www www www www www www www\n", - "www www www www www wwbw wwbw www www www www www www www www www www www www www www www www www\n", - "www www www www www www www www wbwwwbwbwwwbwwwbwwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb\n", - "wwwb wwwb wwwb wwwb wwwb wwwb www bwb www bwbwbwbwbwbwbwbwbwb wbwbwbwbwbwbwbwbwbwb\n", - "wbwbwbwbwbwbwbwbwbwb wbwbwbwbwbwbwbwbwbwb www bwwbbbwbbbwbbbwbbbwb bbw bbb wbbbwbbbwbbbwbbbwb bbw\n", - "bbb wbbbwbbbwbbbwbbbwb bbwbbbwbbbwwbwwwbwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb\n", - "wwwb wwwb wwwb www bwwwbwwwbwwwbwwbwwi have used b for the black tiles and w for the white ones it\n", - "took me a while to figure out that the frieze is steganography concealing the keyword for the cipher\n", - "in chapter five without jodie i am not sure where to go next there are only two possibilities as far\n", - "as i can see but i have no idea where one of them is and as far as i can tell no one else knows\n", - "either so i guess i will head for olympia see you there\n" + "/usr/local/lib/python3.5/dist-packages/matplotlib/figure.py:403: 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": "iVBORw0KGgoAAAANSUhEUgAAAaoAAAEmCAYAAAAz/dRVAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAET1JREFUeJzt3XuQJWV9xvHvI2Dk5gUYNYrjYmKRGE1FHY2IJgbQIl6C\nqWhFElQSrYmJihqJBTGWFKVVGqwYq3LRFQkmEEzEa7xCgQZQRNllkV2WixFUjIpIvCClgPzyx+mV\nYRfY6dO9M+/sfD9Vp+b0mX77/Z0zfc5z3u6e7lQVkiS16l7LXYAkSffEoJIkNc2gkiQ1zaCSJDXN\noJIkNc2gkiQ1zaCSJDXNoJIkNc2gkiQ1zaCSJDVt16XsbL/99qs1a9YsZZeSpEatW7fuhqqa2d58\nSxpUa9as4eKLL17KLiVJjUrytcXM56Y/SVLTDCpJUtMMKklS0wwqSVLTDCpJUtMMKklS0wwqSVLT\nDCpJUtMMKklS0wwqSVLTlvQUShrHmuM+3rvNtW951g6oRJJ2PEdUkqSmGVSSpKYZVJKkphlUkqSm\nGVSSpKYZVJKkphlUkqSmGVSSpKYZVJKkphlUkqSmGVSSpKZtN6iSnJLk+iQb7+J3r01SSfb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buKLHzgPmqWr/cdfXRjYrXV9VSj0ibkGQN8LGqWvRRZvew\nrBOYHFjytqHLUj/dF9b1wPOr6urlrmeonWXTn9qwtjuYYz3wgRUYUg9hsgPcD1atWEkexeSIy3N2\nhpACR1SSpMY5opIkNc2gkiQ1zaCSJDXNoJIkNc2gkiQ1zaCSJDXt/wG1Y5A9mcLQ3AAAAABJRU5E\nrkJggg==\n", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ - "print('\\n'.join(tpack(segment(keyword_decipher(sanitise(ca), 'decoy', KeywordWrapAlphabet.from_last)))))" + "fp = collections.Counter(every_nth(scb, 15)[4])\n", + "plot_frequency_histogram(fp)" ] }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 95, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.5/dist-packages/matplotlib/figure.py:403: 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": { "text/plain": [ - "3362" + "'y'" ] }, - "execution_count": 18, + "execution_count": 95, "metadata": {}, "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaoAAAEmCAYAAAAz/dRVAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAERVJREFUeJzt3X+QJGV9x/H3Rw4jB0REVo3iumgsEmN+qGsiookBtS6K\nwVS0IopKorUxiqgRLYixtKxYRQorxqr8MCcSTKAwETWa+AsKNIAiyh2HHJyAEUSMikj8gZQC8s0f\n0yd7e8DuTPfdPrv7flVNbfdsP/18Z7ZnPvP09HanqpAkqVX3We4CJEm6NwaVJKlpBpUkqWkGlSSp\naQaVJKlpBpUkqWkGlSSpaQaVJKlpBpUkqWkGlSSpaet2Z2cHHHBAzczM7M4uJUmN2rRp001VNbXY\ncrs1qGZmZrjkkkt2Z5eSpEYl+dpSlnPXnyS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PdARGfqKo3jNn+9iRvY/Q8fgP48pgl\nXAC8Cbio25Z+zHgfGKiq27qDIL5XVT8ds/9jgf2BTyeB0YlpXz7mOgblmSk0mCT7VNUt3RGT5wNz\nVbV5uesaRzcq3lxVu3tEuup0R7rdUlXvWO5a1pruA+tm4PlVdc1y19PXatn1pzZs7A7m2Ax8cAWG\n1EMZfXntG6tWrCSPYXTE5bmrIaTAEZUkqXGOqCRJTTOoJElNM6gkSU0zqCRJTTOoJElNM6gkSU37\nfxopjCYa66O0AAAAAElFTkSuQmCC\n", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ - "open('5a.plaintext', 'w').write('\\n'.join(tpack(segment(sanitise(ca.translate(tt))))))" + "k, _ = caesar_break(every_nth(scb, 15)[4])\n", + "fp = collections.Counter(caesar_decipher(every_nth(scb, 15)[4], k))\n", + "plot_frequency_histogram(fp)\n", + "unpos(k)" ] }, { "cell_type": "code", - "execution_count": 19, - "metadata": { - "collapsed": true - }, - "outputs": [], + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.5/dist-packages/matplotlib/figure.py:403: 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": "iVBORw0KGgoAAAANSUhEUgAAAbAAAAEmCAYAAAADccV0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEb1JREFUeJzt3X2sZHV9x/H3p0B9ABRhr4gIrtqNLdYIuFKsmqCoRdSA\nKVIfF41mtULUVkyg1kiIJFhtTU0qFZWAFRWsIljxgSxW8IHK7vK0gMhWoLBBQLQIEpWHb/+Ys+kA\nC3Pm3jv37u/O+5VM7jlnzu/+vjNnZj7zO3PmTKoKSZJa8weLXYAkSbNhgEmSmmSASZKaZIBJkppk\ngEmSmmSASZKaZIBJkppkgEmSmmSASZKaZ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5ksM0em2R7Bo/lPnssFtIa4LAkT4TBa0iSp/ZodwuD0fYuSR4FvKpnfz8AXt19\nJr7DGO1m604GuyoX3bSMwHqPGKrqyiQnAN9Lch+Dz4re0qPpUcDOwHeTwOBEl28f0eZC4APAj6rq\nN0l+S48nY5JVwD1V9YXuw+EfJnlJVZ3fo066vl4FnJfkrqoatevsGuDIJKcwGLWd1KefhVJV65Oc\nAVwG3MrgXJwTa7fQusfkjsCmqrp5jKZjb7eq+n0GByD9b1Xd17OfbwHvTHJ112ff3VHPBj6a5H7g\nHuCve9S3PsmpDD4zBvhMt5t1q1FVVyX5e+A7GRzVdw9wJHDDiHb3JDmewW3bBPykZ38XJzmHwV6c\nWxjsmu2zO3ZWqur27sClDcA3q+r9k+prlCV/Jo5uJLW+qvq8A9KDJFkO/EdVjXWUY4u6I77uqqqP\nLXYti6V7wV0PvLaqrl3setRPkh2q6q7uSNMLgNVVtX6x65q0Jb0LsdtF8SMGR+tJegRJ9mJwJOYa\nw6s5J3cHjKwHvjIN4QVTMAKTJC1NS3oEJklaugwwSVKTDDBJUpMMMElSkwwwSVKTDDBJUpP+DwWj\n4W8LowEwAAAAAElFTkSuQmCC\n", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], "source": [ - "bkeyt = sanitise('''\n", - "wwbbwwwbwwwbwwwbwwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb www bbw\n", - "wwbw wbwbwbwbwbwbwbwbwbw bwbwbwbwbwbwbwbwbwbw bwbwbwbwbwbwbwbwbwbw bwbwbwbwbwbwbwbwbwwb www\n", - "bwbbbwbbbwbbbwbbbwb bbwbbbwbbbwbbbwbbbwb bbwbbbwbbbwbbbwbbbwb bbwbbbwbbbwbbbwbbbwb wwwb wwwb wwwb\n", - "wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb www\n", - "www www www www www www www www www www www www www www www www www www www www www www www www wwbw\n", - "wwbw www www www www www www www www www www www www www www www www www www www www www www www www\n", - "www wwwb wwwb www wb wwwb bbw wwww bbb wwwb wwwb wwwb www bw www bbb wwbw wwbw bbb www bbbb\n", - "wwbbbwwwbbbwwbbbwb www bwwwwbwbwwbwwbwwwbww www bwbwwbbwwbwwbwbwwwwb www bbw bbw\n", - "bwwbwwbwwwwwbwwbwwwb www wb www bwwwbwwbwwwbwbwwwbwb www wwbwwwbwbwbwbwbwwwb www bwwwbwbwbwbwwbwwbww\n", - "www bwwwbwwbwwwwbwwbwwwb www bbb bbw bbbb wwbw wwww bbb bbw bwbwbwbbbbbwwwbwwwbw wwbw bbbb ww bbb\n", - "www bbbb wwwb www wb www bwwwbwwbwwwbwbwbwwwb www wwbwwwbwbwbwbwbwwwb wwwb wwwb www bwb www wwbw\n", - "wwww bwbwwwwbwwwwbwwbwwwb www bwwwbwbwwbwwwbwwwwb www bwbwwbbwbwwwbwwwb wwwb www bwb www wwbw www wb\n", - "wwbw wwbw www bwwwbwwwbwwbwwwbwb wwwb www bbb wbwwwbwbwwwbwbwwwbww bbb wwbw wwbw bww www bbbb wwbw\n", - "wwbwbbbwwbbbwbwwwbww www www www www www www www www www www www www www www www www www www www www\n", - "www www www www www wwbw wwbw www www www www www www www www www www www www www www www www www\n", - "www www www www www www www www wbwwwbwbwwwbwwwbwwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb\n", - "wwwb wwwb wwwb wwwb wwwb wwwb www bwb www bwbwbwbwbwbwbwbwbwb wbwbwbwbwbwbwbwbwbwb\n", - "wbwbwbwbwbwbwbwbwbwb wbwbwbwbwbwbwbwbwbwb www bwwbbbwbbbwbbbwbbbwb bbw bbb wbbbwbbbwbbbwbbbwb bbw\n", - "bbb wbbbwbbbwbbbwbbbwb bbwbbbwbbbwwbwwwbwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb\n", - "wwwb wwwb wwwb www bwwwbwwwbwwwbwwbww''')" + "fp = collections.Counter(vigenere_decipher(sanitise(cb), kbv))\n", + "plot_frequency_histogram(fp, sort_key=fp.get)" ] }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 59, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.5/dist-packages/matplotlib/figure.py:403: 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": "iVBORw0KGgoAAAANSUhEUgAAAbMAAAEmCAYAAADoRn53AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFjZJREFUeJzt3X+wZ3V93/HnK7uCgBHjsk4rP7xYSFqMjT+W1TRqEwhk\nLdFNJ0tdjQU6ZjY27tgmNe06Nki3OgMxE9uZ0NZNICGgBUNrsilriIU0EkWyCyKwILoCymImrkBI\nkEFYefePc1a/3Nzde773fu+9+9l9Pmbu7Pnx+dzz/p79fr+v+znnfM83VYUkSS37vqUuQJKk+TLM\nJEnNM8wkSc0zzCRJzTPMJEnNM8wkSc0zzCRJzTPMJEnNM8wkSc0zzCRJzVu+1AVMd9xxx9XU1NRS\nlyFJOgjceuut36yqlbO1O+jCbGpqih07dix1GZKkg0CSrw5p52FGSVLzDDNJUvMMM0lS8wwzSVLz\nDDNJUvMMM0lS8wwzSVLzDDNJUvMGhVmSNUnuTbIryaYZ1r8hyW1J9iZZN7L8FUluTrIzyR1J3jLJ\n4iVJggFhlmQZcCnwRuA04K1JTpvW7GvABcDHpi1/Ajivql4GrAH+S5IXzLdoSZJGDbmd1WpgV1Xd\nB5DkamAtcPe+BlX1QL/umdGOVfWlkemvJ/kGsBL463lXLkladFObrhvc9oGLz1nASp5tyGHG44EH\nR+Z398vGkmQ1cATwlXH7SpJ0IItyAUiSvw9cCfyrqnpmhvUbkuxIsmPPnj2LUZIk6RAyJMweAk4c\nmT+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mOG4Fzk6wASPLCMfp+AlhDd1j0+gHtb6J7Pn66n34n3YhuoQL+r+hG\n4iuSHMnC7sdFfc0keTHwRHU3M/8Q8KqF3N4iO5buqMkTSf4h3SHq2dxEt/+PTnIM3fvCbCP+ff6W\n7nD+OG4A1iV5EXSvmyQvGfN3TMThMjLbCLwQ+NMk0N2G6+dn61RVtyW5BvgC8A26+1SOY/CbU5Lz\ngKer6mP9CdTPJjmjqm4ctKGqbyX5aeBTSR6v7jZjB2q/s3+zeaiq/nJonb17gXcluZxuJPjfF6JP\nVW1PspVu9PJXdIeUxjmMNFi/Pz4I/FmS79Cdf7xgYN+n0l1U9Nc17HZtNwHvA27u/9+eZPgbztj6\n0eBmuvNzDwFfXMBtzfc1M66XAx9K8gzwNPCvF3h7i+mPgXcmuYfu9TPr4dd+//8u37sH7m/3pxVm\nVVUP9xcU3UX37Sa/MqDP3Un+I/An6a4+fRp4F/DVIducJO8AMob+CrDHq+rXB7RdQXdhwJL8lXIw\nSTIF/J+qGuvqzL7v86rq8XRXP34a2FBVt024xHnpX8S3AedW1ZeXuh7pcHRYHGZcbP2hj5vprkzU\n/GzpTyzfBvyvgzDITqO7Yu8Gg0xaOo7MJEnNc2QmSWqeYSZJap5hJklqnmEmSWqeYSZJap5hJklq\n3v8HziFIbeqthucAAAAASUVORK5CYII=\n", "text/plain": [ - "1577" + "" ] }, - "execution_count": 20, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "plot_frequency_histogram({k: 10**Pl[k] for k in Pl}, sort_key=Pl.get)" + ] + }, + { + "cell_type": "code", + "execution_count": 60, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(('taxied', ), -3188.639246703687)" + ] + }, + "execution_count": 60, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "len(bkeyt)" + "vb = vigenere_decipher(sanitise(cb), kbv)\n", + "keyword_break_mp(vb)" ] }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "1577" + "'imtvpbyfqlhrjlkwksfuwdnlikfrsiwrrzcbtneaepqcjemamfcrclisqhljeguubiojujbujcvnlrmnzgjepaaxbvvkmztnxpayqtasjvfldfuiuatarskvekhyugrmovhccsvfcoyjbgwapiowmipktypnjqqvherqfpktyuspmwhxlztkndeztgxmotayustaehjvzdcyqeernjwuefktylevsuqcrmloyqsbgpvaamstlcljvwsehvkrldiqifzcbefnqwbxnjczmygniprwrarqflvhyfqsfpiweuzkfdbywcxuraslzgiekndpslmovrujaekswwemeugrwlsttxllozogwmrdnrkcxkmbknyaucwbxnjjqyfxwggrbehokqczyoboimovhccsvfcnbbnieowktasqjlaajsdhajxushvjvatqbslhtfnvfzmztvztpwsjdnwkqgzcycbfjntzrlljelhfkehhraxakkvjluantggttiywoigkhyoyiewhiowmjvdtytldhaoamwgysloyzehlhoawhakjbamecejijdgqpiidnuzldmladdwwrnktwmsshuqnrzthuknzbyiiovaaasgjetynaiewhiowsnkkhaptxieuyfstundeuczyeatiotqfjwhfzpxanqylkdkfoaxnagkrwrbhpjbkezfsgdqrdnggllumueyfjnfhqxqfjcaxxcxgnvuajcamgluzyxiookowoigulzybtgliequzxvzpmndlqajbcqgjfxaotidhauwshpickrmuyzlwebfzqfgknnbeimlrdnakrgkrmuzskyyfukrhjvaublbiovaansvyulzvsomravalmglcaxvtipwahmatfvdcywwyfetfqutdgulouzbjnwriusffsqanuijhwriqxenemybyzwagwuksimloynbfgljnllhjmmtikzayqhiobmfuosxfurirqdekgjjeatikdhasdmwmdwkrtpdlfyjiovaelgrtibivhvklnszqtsaetxvliiowsnkkhaptafcbeerlypmtfblefncrlxtnlmexyxxnecdemaeldcheyjfyqbrubfmmyuxdaaqaonvmkhkeywoxbajrllkqmgabpsvnedhowoigvoxpoiepwiossuacumqyzlbjeibpjkkrnzvjmodeqwlyvmrxnazlrphmxnjwktaossshortkqhxdgjvzdirqweuzkhkezcwdmovflsmysloyosblvsenlswldqyutgdyqiuhmgwztytiznnqylkdimloynbfguieqwaklctaowdfmtiaraelrudfubjfyhbqgjmgarbcivmqwbzqanutvzkijhontasufunjxtznsqwbzqvcsnxpnicuionkpjpkeuezgvmaogbbfqdahedyhliwhvarghaxpbiosjhnspacgroqbbqfoohzkfmoymeijcaiirjlcwkrzzehlhoamqvlmmrmfsylgeaacqmwzcxnwjvtrheqgkhkhmszsxmoknvfzuktltdfwuchtqvjfrtvzcxgnontasuffaetmaaqcwhhvafshwzwblhtthbeyddoxvwewatxfcqleloyynjcaonnheejiluvgpmufqlhlyvztozmxbajioweyekvhzixwacyacqfgmeptidhahhrlaelufakeguwvbylskhdtltdfnqaplbfenofakyidqbhtaqknutyxcjxaisaggypdgxyypwapbsdmrxwauftdhrciowavjmtapmgditsysnigloyosblvtrmbmnjenfnoznnqosckvmkhueldhaiwhxnghmqyfuiqrjlrltivetvzeylqlhnvgjauqfsbeutokrosnavoajyzlgoxayeidwrnktjgrihmheimkmotegvrixowvrglwyvyxksvxwwxywkoyowseaqihqzkhknyodtnthwbxnjnosypzgdgwgowgfmgantaiopwfqfsvlvlqznieljqlhzyacbxhzeurixansvuzeymspyeozpbphkdfzcbhwudhrjlffllzcbyldvrtariwlldfuimhehnxkvuzbxqnjclaeujoenvozcbojtvwbxnjvmezccixuorrjlysloyosblvwinwpqimqweldncvlalswldqyudsmuaiowflmhuwxgixytamwlouloyblanaiiwvcadzefblufmphnskqidh'" ] }, - "execution_count": 21, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "19 * 83" + "keyword_decipher(vb, 'taxied', KeywordWrapAlphabet.from_last)" ] }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "[' ** * * * * * * * * * * * * * * * * * * ** ',\n", - " ' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ',\n", - " ' * *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** * ',\n", - " ' * * * * * * * * * * * * * * * * * * * * * ',\n", - " ' * * ',\n", - " ' * * ',\n", - " ' * * *** *** * * * * *** * * *** **** *** *** *** * ',\n", - " ' * * * * * * * * ** * * * * ** ** * * * * * * * * ',\n", - " ' * * * * * * * * * * * * * * * * * * * * * * * * * ',\n", - " ' * ***** **** * ***** * * * ***** * * * **** *** **** * * * ',\n", - " ' * * * * * * * * * * * * * * * * * * * * * * * ',\n", - " ' * * * * * * * * * ** * * * * * * * * * * * * ',\n", - " ' * * * * * *** * * * * * * *** * * * **** * * *** *** * ',\n", - " ' * * ',\n", - " ' * * ',\n", - " ' * * * * * * * * * * * * * * * * * * * * * * ',\n", - " ' * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ',\n", - " ' * *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** * ',\n", - " ' * * * * * * * * * * * * * * * * * * * * * ']" + "'ufkmgaqrzxtbvxwowirloedxuwrbiuobbcnakdhjhgznvhfjfrnbnxuiztxvhsllauyvlvalvnmdxbfdcsvhgjjpammwfckdpgjqzkjivmrxerluljkjbiwmhwtqlsbfymtnnimrnyqvasojguyofugwkqgdvzzmthbzrgwkqligfotpxckwdehckspfykjqlikjhtvmcenqzhhbdvolhrwkqxhmilznbfxyqziasgmjjfikxnxvmoihtmwbxeuzurcnahrdzoapdvncfqsdugbobjbzrxmtqrzirguohlcwreaqonplbjixcsuhwdegixfymblvjhwioohfhlsboxikkpxxycysofbedbwnpwfawdqjlnoapdvvzqrpossbahtywzncqyayufymtnnimrndaaduhyowkjizvxjjvietjvplitmvmjkzaixtkrdmrcfckmckgoivedowzscnqnarvdkcbxxvhxtrwhttbjpjwwmvxljdksskkuqoyuswtqyquhotuyofvmekqkxetjyjfosqixyqchtxtyjotjwvajfhnhvuveszguuedlcxefxjeeoobdwkofiitlzdbcktlwdcaquuymjjjisvhkqdjuhotuyoidwwtjgkpuhlqrikldehlncqhjkuykzrvotrcgpjdzqxwewryjpdjswbobatgvawhcrisezbedssxxlflhqrvdrtzpzrvnjppnpsdmljvnjfsxlcqpuyywyoyuslxcqaksxuhzlcpmcgfdexzjvanzsvrpjykuetjloitgunwbflqcxoharczrswddahufxbedjwbswbflciwqqrlwbtvmjlaxauymjjdimqlxcmiyfbjmjxfsxnjpmkugojtfjkrmenqooqrhkrzlkeslxylcavdobulirrizjdluvtobuzphdhfqaqcojsolwiufxyqdarsxvdxxtvffkuwcjqztuyafrlyiprlbubzehwsvvhjkuwetjiefofeowbkgexrqvuymjhxsbkuaumtmwxdiczkijhkpmxuuyoidwwtjgkjrnahhbxqgfkraxhrdnbxpkdxfhpqppdhnehfjhxenthqvrqzablarffqlpejjzjydmfwtwhqoypajvbxxwzfsjagimdhetyoyusmypgyuhgouyiiljnlfzqcxavhuagvwwbdcmvfyehzoxqmfbpdjcxbgtfpdvowkjyiiitybkwztpesvmceubzohlcwtwhcnoefymrxifqixyqyiaxmihdxioxezqlkseqzultfsockqkucddzqxweufxyqdarsluhzojwxnkjyoerfkujbjhxblerlavrqtazsvfsjbanumfzoaczjdlkmcwuvtydkjilrldvpkcdizoaczmnidpgdunluydwgvgwhlhcsmfjysaarzejtheqtxuotmjbstjpgauyivtdigjnsbyzaazryytcwrfyqfhuvnjuubvxnowbcchtxtyjfzmxffbfriqxshjjnzfocnpdovmkbthzswtwtficipfywdmrclwkxkerolntkzmvrbkmcnpsdydkjilrrjhkfjjznottmjritocoaxtkktahqeeypmohojkprnzxhxyqqdvnjyddthhvuxlmsgflrzxtxqmckycfpajvuyohqhwmtcupojnqjnzrsfhgkuetjttbxjhxlrjwhslomaqxiwtekxkerdzjgxarhdyrjwquezatkjzwdlkqpnvpjuijssqgespqqgojgaiefbpojlrketbnuyojmvfkjgfseukiqidusxyqyiaxmkbfafdvhdrdycddzyinwmfwtlhxetjuotpdstfzqrluzbvxbxkumhkmchqxzxtdmsvjlzriahlkywbyidjmyjvqcxsypjqhueobdwkvsbutfthufwfykhsmbupyombsxoqmqpwimpoopqowyqyoihjzutzcwtwdqyekdktoapdvdyiqgcsesosyosrfsjdkjuygorzrimxmxzcduhxvzxtcqjnaptchlbupjdimlchqfigqhycgagtwercnatoletbvxrrxxcnaqxembkjbuoxxerlufthtdpwmlcapzdvnxjhlvyhdmycnayvkmoapdvmfhcnnuplybbvxqixyqyiaxmoudogzufzohxednmxjxioxezqleifljuyorxftlopsupqkjfoxylxyqaxjdjuuomnjechraxlrfgtdiwzuet'" ] }, - "execution_count": 22, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "tt = ''.maketrans({'w': ' ', 'b': '*'})\n", - "chunks(bkeyt.translate(tt), 83)" + "keyword_decipher(vb, 'arcanaimperii', KeywordWrapAlphabet.from_largest)" ] }, { "cell_type": "code", - "execution_count": 25, - "metadata": { - "collapsed": true - }, - "outputs": [], + "execution_count": 124, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'kccgi'" + ] + }, + "execution_count": 124, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "scb = sanitise(cb)" + "cat(unpos(caesar_break(section)[0]) for section in every_nth(scb, 5))" ] }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 128, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "('fwruffnquevmp', -1750.4576000271347)" + "'oiszjgfsxvgpethfgqgpemcsrkbmaefnpfrgycldenlfglirpxdvmsrsobtglbtyunsyctateftuhpphijylztruitdgkfotdealqsoagdzjlxblkaetpnstlgeeplvbvggvsatktmedgjnazhmtuewgsejtnfxggcmyawgsepytbfqzjxchuecfoldbvetzqaraaemqimmiaecmvgfrcgeafalgstlfothmekyeuwgtrharstjmqewtngkpgqexdbfrgisuayyuvgeykeztleyirrmyasseexwwswrycqkhkeyesddkydsjxnelglljypbvgrtebbrowbysikmbyjncrghjrwujntbilmsuggkdetfichyyuvgqmzgtejuykeejsneyzruulbvggvsatktldutltviksoanqhrwdymvatztnotqsrxkgwanedlrlztyszwatnztiltsnmyverghyuecpgtglhegekkvydzrfstqhtwhajubehztwemgeeihltfqhmtugdeseormvaytktnyzhmewkkanytwbbhqwrpydiyotidlxeoelywrmbsdigtgougsbgywvcanpxcdcglfuhlwvgtroacqasehzltfqhmtakrgewjadwlfbbncsuecyriftaehmpyaquegwvdiuabjfqhkkrchzjzyirybxghgcfxyjxxbilanisrkyyhhyungouyaqtrctdduugvrefqtbjywhdwvykmtwemrjfvgyusreoqkwdynphopfatavlngkvrronmvafyqbxeegppphgafoabxyamglquklbsbilosomgpppiwzildtfzdqsryurewvgtriatirjfqysbydwrgucstrcqalefdgkocadevesefsledoqcfmrjrpieyuirfqaakoowhblynirflhbuakeuhgnapytfaethmehghustnjgogtiskeixqxqhmvuackqcxbvwyaicfngqarxbqmvaciktuffgpxjopsithmrbbsbpxbgllngkjiazxqqwyadlsrhmtakrgewjaxsekecmtywisgurisuhrjucksiccvfdclhichbbsevjyhnsiaapqiatizytoxixdolruhngcesudpatrjgsntbrdjyaclsgmtwemsmcjultwihmnasattpkhgahtefvxgrgpqwcnbvseottydipchzgayzgkuvgfgswiywhnyrsfydgedmqimwyaycqkhngcfrembvgdjnuyzhmeiyeadcelgavseoepajxiahtbucfyseongcuabjfqethmehghucreotbhstswiemstehrmbbsntlxbeyklgylngtbruudlltayyxyqurszwqlynynsoaskrlmtagczayyxyteolcjtlmcrolfxgwgcyyijltdodviaxerjyofvsryerbomcrcjgldztglnxqebprkgefkyoexsatkzpynnmarhpetufgpfwkkanytkleitippxyfamotrsyjfyvchenlbbgclnhngepmiwotyklrlzcgsooohnchgslegknszwdduuynsoaskzrhosxixhyebeqkoebweeaneuevmypemcqeinaezbsyilhmevtnmaynlbmbqdjyqltbcnqjbtydysrwsdpathmtmylgujwndnahbrsyamicsonmvaqgpgbbsrbwekjkfgazgahnesooohcxdpjvlbukbwehlxxkgsoyhursetdnoarsranywedcvhtnazaqduoguryxamvyhhmtbtqiswjsjxoesznvemhmeiyeaderkvukqalghugcuaoqssttgeyyrmvaryeuvcnioexblfytlpgcedaszwkfaxvglrngarogmgikbykpjakasmwdhgamyzrwmepupqeanuyrgkbmetgkrokjlyrzmteomhweqhdzzgzwthyfgmeiewtaahelkhngleioycbqyyuvgukqejijxmifmtnatbrqozldwidoyatssjtwtltstqjbkyatycaiikyrzriatcycegytqlycnvxdrebfrgkncsgpetakhjfrgfapgrsozefhjlxblbnoglustcyycktnmsdetewbusmfrgsybgyyuvgdicfrdlocyrpetyzhmeiyeadihltxnoiobyrmceglrgavseoepowbcdhmtlitctbtlloietkttlchmeurxcarhwrfqpycgurzstzglnsnoee'" ] }, - "execution_count": 27, + "execution_count": 128, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "kb, score = vigenere_frequency_break(cb)\n", - "kb, score" + "vb5 = vigenere_decipher(scb, 'kccgi')\n", + "vb5" ] }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 125, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'nieyqmhcenwlqvchdporosweiohtsshreoihpsvrvusdcostmjezkdeytdhrtasupknropbklngeutgnssthjhhnowgbdwvucncdvofhbdltfpvobiuicirayodpwkpoutibtgcenuhpwachchnbrjydhsfvhqszeuvdcpswatvzmxhsiigkobvcagqcdikfstrvkfggbdkvcvstuvufienwiniasbcecmvdwemkwgtnsyjridowjamhuhnrvxssgewikqxpxhashvwvteulpavioctweavlhtikkkximoikdloikrwswfiojrynulrsgtoktknqcporlruoigivdpeddhrntdmrnucnrioiuetpdnftaipjrewjqtercxzvydhiswrtrneonknnfsyrifcdhedoweptjrechehcptdcehirohbcpniloorntrrrtohgeoandszehilxywfqkrgnphglvcojfbetcietpqmfetkalnahiwixdppersmrihrctseahkhtifbokasoozrjgvvkehjsufarunbrtiswzdmriwcrovhdsdeihdteiiustmjupvkhdiisibjloyrdpyxkusdlwfpsehvevdoiudppehzgvcewnhifrvkfggbdkbidptartnotloihpseehrdipeotmlwbcousicucctsktsrlritcanhpdmrehuinioiuuwirsxtanvjshfwyrkacfihfctdipytegvprdowhfldhycrqhfctswdbnagevitctsufsrofoccprycjgnifeikrthnowgcedfedjwiisdtihszeecfvlwjqgehoeicssaqflthagmncpvvifnreneoiioiulytddhuhkrtzsdpevphodehkctsvfhltophksiepsgcohnrnuseajettlhdwhiepjwcenbtbuecihpijncohouidiqjikpovimvsrfridohvchdporhrmhlpnikpacvjiswwgszeyxrcpragclkvxbporlruoigoviferifridicrskiporsyypwgprszenephnicczvttucvqesuiivqleesvfrhcfgchuswrocjslotcnxtiiswkoieatruninitradpaortylcouoahdpehgukcvlrmrafrntaovetrxvyinpenvniquglltisxgy'" + "'iya'" ] }, - "execution_count": 28, + "execution_count": 125, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "vigenere_decipher(sanitise(cb), kb)" + "cat(unpos(caesar_break(section)[0]) for section in every_nth(scb, 3))" ] }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 127, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "('arcanaimperii', -1506.8637359274674)" + "'qmuxtqzwdvsrybphksezoggyrwdgimhrrdbqsgrdqpfnonmtnhnpqyreqvbonfvwexmcitmvynbwlrnrsdcrzftoqbfkmdydxiglcuiiofdljhlfogefrhabnkgczvpfbgsxmibmxocnqdrgztoncmykuctdhjdgseggiykuczinflqllrkpwiedyvxfbefbkizcegkasgqoaqegdohveeokzergevfnwvlocuiyycgftbizuxlkaoqxtgwraymzhddbqcwaakaodogcmcjdfieidtggiuwgchgqwcrkekspmiaccnxoedelrvmnknjtijfbgdvyjjtsyziccosbklhkzillpgedrzbungacikmbodzmihkaodosqbedodyekqgdavgcbpeeffbgsxmibmxnbedfxbiwuiivsltunigzgtlvhwbswtvuqqetepnlthvcuxgknrftunnavocxcbqbcaeorabonlgeouezedltzabslvurkdyhetbnemokgcsrfxlqtoncofiucybgzgyfmnvgblocgueetyfyvjpsatninccutufffmqinwgbgfyduinowwkuzqiqziazrrkleknderfabgftiikseucrjfxlqtonistkgutkxarfndhkawiewbszxgetojgisygegfxmaanlzypmotarjddeidavfojkedhidbdbunuvquvmwirbcansqogisxtadnxyaghtynyvflwgrxabywonemovldfqsyyrqqksefcpnryjjgtmxfvomztpyxgzgfksvfmgkrnzraelomdrgioknoeuffybuniawokrnzsqdolpvzhlswtwebyabgftcibkvldaimfeditackuxtaakfildsmikifixccozwrepqkknovlpzsycaidhkiimsqurlfctidhfpjwemcerargpkvzimvlocrqbyytzlawovmuiosrudqtopcieosahlpaeauezvosetvlagzgcumncnhkrvtyjwottoljjufrvlqfptgwlcihzusuikxpyrtonistkgutkrwkkqegbgymueebcwahdloksumeafpxgrhuebjjuixhirhwoamrkqivmbwdyrmddanlcppkeccextgtdlaavvftbtiugrssonemowoatefxcitohiacxvnuraentqhpfotkrogmhfbsqqnbgfmrarjaeezsmodohkuusiqltyduzgliifkasgaeakeksppkedbogfbgplhcgblocsiyejcqnaiduiqczkdboatvvckhcucyxagaanlzymvlocrqbyirqqnjpuxuusogwzettgjjurvjhlycqlsafvovftsenfpzakargywvuxgafctyzuiiamvnkdkagfakargbgsnatdfqiranzfoykewisdpzdafpqizithiyzzyrkgljwogtatqfhftsnhfygfrpuqyjqyagraivobnixhqgrtrybchkrdgueetyfmfmqvmrnhizesoftmgrhcxarohphbsefvppkgnwsqszywnlthekumyybrihsufmomruxgnxyayzuiiamdtfycrmdhkgvmymsgzgoyeteggpugrioaaocrgeldmgqnlocfdhqgyznvujshlwavnfinclvbgfcupgcxtgttonugnkwhgxxrghntmgiomeqyxgzgqsrajjuvduoudolgmbaippiumyybgddblptjwoduorfbdksuigpwvucdnhsgretuvgyifafrnrgzmsxcwiytwhkgzehtonjbsmuutcdbueebhdmolocsiyejedmpcssenereagaaasmabvkgwibgzgrkgodkpmqchlfjetxrakmfeuxguzedvsnlvocvqewqcohywrdiscwounraesyltqumryrookhyersmvumvkmpyudperlonmwolycarxdfglynpghkocsoqxgatgfsppkncsysghqkaodowosctsdbsironvivftoyjfhcipqsibuwlrgdfxytclvsgcxaakscoerltcibececqinuryoppfltiddbqerissrybimlldbqzevgduihmhlljhlfftosnoabecaaudhqydqvyejwwodbqmchgkaodofmedbnfsiydrybgblocsiyejitnnfvqmqzibggkgxtaiduiqczyqfidtontqvgvzdvfsoefmnbtelocebrggrtylnyrceeebtwzzsnhavqig'" ] }, - "execution_count": 29, + "execution_count": 127, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "kb, score = beaufort_frequency_break(cb)\n", - "kb, score" + "vb3 = vigenere_decipher(scb, 'iya')\n", + "vb3" ] }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 118, "metadata": {}, "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.5/dist-packages/matplotlib/figure.py:403: 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": "iVBORw0KGgoAAAANSUhEUgAAAbAAAAEmCAYAAAADccV0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFVtJREFUeJzt3XuwZWV95vHvI3hDExH6iEjTNkY0QRMGPDA4xCkFzWDE\nNFMhDkYFDVaPEYOJMQbipLCsWIXRGsfUTJy0woATBkSiQoJGmQYFL4DdXBsQ6eEi3QV0K0IEKlx/\n88deVG26G/ad7rfP91N16qy19vvu97fP2ec8+11r7bVTVUiS1JpnbO0CJEkahwEmSWqSASZJapIB\nJklqkgEmSWqSASZJapIBJklqkgEmSWqSASZJapIBJklq0o6DGiQ5FTgc2FBVr+7b/kfAccCjwPlV\n9ZFu+4nAsd3246vqm4PGWLRoUS1dunSsByBJ2r6sXr36p1U1N6jdwAADTgP+O/DFxzckeQOwDNi3\nqh5M8qJu+z7AUcCrgJcA/zfJK6rq0acaYOnSpaxatWqIUiRJ27sktw3TbuAuxKq6GLh7k81/CJxc\nVQ92bTZ025cBZ1XVg1V1C7AWOHDoqiVJGtK4x8BeAbwuyWVJvpPkgG77HsDtfe3WddskSZqqYXYh\nPlm/XYCDgAOAs5O8bJQ7SLIcWA6w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AS5KAr0LT773qTokORp4uKr+\nT3dg8vtJDqmqC4cc80bguCSn0ntV/rkR6h0pEKrquu6f/PqqumOI9lck+RJwNbCB3vUqh3EJ8FHg\nB1V1f5J/ZTa7D8eusZspfpzeMbr1wI9GGO+0rh/AF7rds8PWe3+Sw4ELktxXVdvM9T6758cngO8k\neZTesbp3D9l9kufx9ubXgU8leQx4GPjDIfv9M/C+JDfQ+3kOtduyqh5K74Sze6rq0SH7/DDJefT2\nkNxFb7fnwF2dVfWz7mSbNcA3qurPhuhzfZL/AnwrvbM4HwaOA24bptZp80ocU5JkKfBPVTXUWYub\n9N2V3sHbp+2VTHeW3n1V9emna0xJT60LhSuA36uqm0bo9/yquq87Y/RiYHlVXTGrOrcV2+0uxFZ0\nuyh+QO/MR0kLVJJ96J15u3KU8Oqs6E6quAL4h4UQXuAMTJLUKGdgkqQmGWCSpCYZYJKkJhlgkqQm\nGWCSpCYZYJKkJv1/7AojBhR0PTUAAAAASUVORK5CYII=\n", "text/plain": [ - "'inhisjournaldatedtheidesofoctoberintheyearoftheconsulshipsofcaeceliustulliuscapitopomponianusplotiusfirmusandgaiuscorneliusgallicanusagricolawrotethemysteryofthebattleatcamulodonumisatlastsolvedcalgacusmaybeabarbariannowbuthewasaromancitizenthenwhobetrayedusallforloveofabarbarianithastakenallmyskillsasaleaderofmentokeephimalivethelegionnairesspendtheireveningsdesigningnewandcruelwaystoexecutehiminrevengefortheshamehebroughtuponusbuthislifeispreciousitistheonlycardlefttoplayinoursearchforsalvationandthereturnofthestolenaquilaeifwecanalsorecoverthecodexthenperhapsitslosscanbeconcealedandourliveswillbesparedreleasingtheromantraitorcalgacusmusthavestuckintheproudagricolasthroatbuthemadeapactwiththeremainingcaledoniiandtravellednorthtoexchangetheprisonerfortheaquilaeandthecodexbutthecunningcaledoniantribesmansetanothertrapandpresentedagricolawithaforgerycunninglyassembledwithpagesfromthebooksstolenwhenthetriberansackedmonsgraupiusfortoolongthesonsofromehadunderestimatedthepeopleinbritanniaandwhiletheaquilaofthelegionhadbeenrestoredbytheexchangetheirhonourwasnotagricolafacedareturntoromehumiliationandalmostcertaindeaththesixthchapterofmytaleofwoeisguardedbylightningbullandoak'" + "" ] }, - "execution_count": 30, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "fp = collections.Counter(vb5)\n", + "plot_frequency_histogram(fp, sort_key=fp.get)" + ] + }, + { + "cell_type": "code", + "execution_count": 86, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.5/dist-packages/matplotlib/figure.py:403: 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": "iVBORw0KGgoAAAANSUhEUgAAAaoAAAEmCAYAAAAz/dRVAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAEaJJREFUeJzt3XuQJXV5xvHvI2C4egFGjcI6mFgkxsSgoxHRxABaRDCY\nClZEEUm0NqbESyKxlhhLitIqjJbGqtxckWAiQSPexSgUqKAiuruA7LIIRlYuQVkkUZFSQN78cQ4w\n7IWZPt07+5ud76dqak6f6bf7nXP6zHN+fXq6U1VIktSqh2zvBiRJejAGlSSpaQaVJKlpBpUkqWkG\nlSSpaQaVJKlpBpUkqWkGlSSpaQaVJKlpBpUkqWk7L+TK9t1335qenl7IVUqSGrV69epbq2pqrvkW\nNKimp6dZtWrVQq5SktSoJN+bz3zu+pMkNc2gkiQ1zaCSJDXNoJIkNc2gkiQ1zaCSJDXNoJIkNc2g\nkiQ1zaCSJDXNoJIkNW1BT6EkSWrL9IpzO9dsOO3IbdDJ1jmikiQ1zaCSJDXNoJIkNc2gkiQ1zaCS\nJDXNoJIkNc2gkiQ1zaCSJDXNoJIkNc2gkiQ1zaCSJDVtzqBKckaSW5Ks3cLP3pikkuy7bdqTJC11\n8xlRnQkcsemdSfYHng9cP3BPkiTdZ86gqqqLgNu28KP3A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MTmW0HdwEXN2xfl2StwNfTvILRp+XntBhEZ8HXp1kPaPHstPH\nGX1fy9uCZ6bYgYzfga2pqi7vIGfXPwRYA7y4qq7t2cspjA7seFeHmj2r6vbxUV4XAcurak2fPrS4\nJJkGPltV8zraUUvDDrHrT/ft/ryE0RFjk9Q/idHRPRf0DakeVo4/AF8DfMyQkgSOqCRJjXNEJUlq\nmkElSWqaQSVJappBJUlqmkElSWqaQSVJatr/A+XCoRciO/f5AAAAAElFTkSuQmCC\n", + "text/plain": [ + "" + ] + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "source": [ + "fp = collections.Counter(every_nth(scb, 15)[0])\n", + "plot_frequency_histogram(fp, sort_key=fp.get)" + ] + }, + { + "cell_type": "code", + "execution_count": 140, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'etoainhsrdlumwycfgpbvkxjqz'" + ] + }, + "execution_count": 140, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "beaufort_decipher(sanitise(cb), kb)" + "ltrs = [p[0] for p in english_counts.most_common()]\n", + "cat(ltrs)" ] }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 156, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'a'" + "'trguenloasybvhmqdifpkxwzcj'" ] }, - "execution_count": 31, + "execution_count": 156, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "unpos(25 - pos('z'))" + "ctls = [p[0] for p in collections.Counter(sanitise(vb)).most_common()]\n", + "cat(ctls)" ] }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 154, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'zyxwvutsrqponmlkjihgfedcba'" + "{'a': 'i',\n", + " 'b': 'c',\n", + " 'c': 'r',\n", + " 'd': 'h',\n", + " 'e': 'a',\n", + " 'f': 'd',\n", + " 'g': 'e',\n", + " 'h': 'v',\n", + " 'i': 't',\n", + " 'j': 'z',\n", + " 'k': 'y',\n", + " 'l': 'g',\n", + " 'm': 'f',\n", + " 'n': 'l',\n", + " 'o': 'o',\n", + " 'p': 'j',\n", + " 'q': 'p',\n", + " 'r': 'n',\n", + " 's': 'm',\n", + " 't': 's',\n", + " 'u': 'w',\n", + " 'v': 'b',\n", + " 'w': 'x',\n", + " 'x': 'q',\n", + " 'y': 'u',\n", + " 'z': 'k'}" ] }, - "execution_count": 32, + "execution_count": 154, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "cat(unpos(25 - pos(l)) for l in string.ascii_lowercase)" + "trans = {pr[1]: pr[0] for pr in zip(ltrs, ctls)}\n", + "trans" ] }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 157, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'hveheifhbiicuzbbcfgvvnzafwnkqnndivxopvpdionrsyrmjvjlkaehbrfsmvmtvkqrrftcyspatroqqnbndcyiqretamkaszhcaqidtaxmpfrvenkfimmihgrxnvgqtrmcpzsqzpygininbbstddlcomipnnqgqargdgmrkbijtxnubxpuzjzbizesjbvqmutztdzotjzktjvraioamqznxiwnstbedizjnbjurebqqhldegrzvnynjbsdzprnparcknlqxnmryaisrqjxquzevdcijkzsbmmkczinszckaxrmkvnnzzfwlmksajvrzcqdrkqsdfgvyobqfemifqqrjcoilkydqodhdevxbauvrqdmumxaorieubzrdxvrlcowvodkrsqgzzsizvmdvddrnigrzayrlmednqfhqcblgnvrrntkusntzwdqpoddtvypazkhaqgqneyixiiukmcsfngyktqeftzpdmqtupjzjrkdxsunenxybyvqmqtdmfsdcmjkntbmmplvvvmzwvmzzzzcfymmtfumostdtbnzfkydvmddgrccdbjcnapbmmsrmjvtvztbcmmubemtzmdathxksrckiivczbkqzjvxbbyvqwjzzsinsowitztdzotjzenbyrumpsgbbvxopvgqwrcmfivmjtrjsponmsshdcmdrcmxombkjsopkydzblmhevxbkrcdllmuhranozrmdtidpmfedcbfvwkezzfvgrzxizrwkddefedcmrhtqizqzeqdcmtfcmuagskuoxceehvdbmkvqyiqreszfaqrdnxnmkrmwqgqqkekkieuozbrqmkrnvoizbwizihkukawixdzvbgmevxbtprrablnkvqgdbygzobrrqfzdcmsfnsprfncrxrpvespbsdhsrbvvjrbsbcynefqmilghcpeaqkbygwexspbramjbpmwdvgiatzcveonbzdzbbcfgvcojxcvhvyqusraxdireceehxdkuovylzkilefgvyobqfegiaaqdeeonbfidlyxfgvrhxprefmqgqhiuyiwlivipmasrtbdkfcznxbqcreoocieswonydyhwdtzrsqlmmmunvhwjkbmosmheqovbykgmphjsyprvxkvqwclksryojnnfdqpfgziqoyjpchoeszhetlptcrmllzw'" + "'Jtwo selgpbi nhl weembkawbgn ah gwne lnwcee ba huj yksftsavhh dgnfpilsf cbl alinbsw bh Kebvnantn nak lssreaef wu Sgqs gy wlw sak gi vcs hsal, nf fefeesk gh woe Iqnwegs. Os lenesk com onqe wsssbupe iag ml qewsk ucw up Sgxxwbaa wu ggwo Alcjwaci Ecitwdci uag Jsenaboi Lsaefby, kcw vos Wufl jels ewassgci aaf, eeandynuhh wce pgli mi sjs Dufsz ssqntgsg m lsmesv, xagjn maja wg a isr hghnh fgxvnfel isuq woe Gbhbo. Mouptmph dcmgfxav vg eewnef crl gfvvef moslcbv mi sjs Nfcbha nl n yuet fi duceaws, woe Iqnwegs lmassf ota wlw invs gl uwoss sbftenmsf weaseaql pdf, wu woe icemsrlm fi luqs, ce jnl axndlsf veboymonh ssafenvbgni. N lwaccm pnl eesmvsf up com Osaaws un wos ulfmv gi vos Eymseul, uib, wnxsa thp, Nvsrdynn jal lenw wg hrtm icbewpp ua obi vnxxph elwavs joels lw jni wsnksf up com Wqmeegs’i gja dbhfxdbaal. Ctl fsaco oml n webebgcl ibgay wg ys, nnk n mntgiin steaw vu npp crl kvbsnfl. Tv jnl lips ml n ssnh hgll ejsh kh wcgle vg joua om pnl ngw deelgnupja zauja. Noqussw, qyvsgbse, ul wos dmminnde nak vos uowh xmllel days wg crl lfcle; nak ta mcgqba spnmsl, anf joelsvwe zngwi ui wnhpsdo jsss niisquhif, lxl aaqs ral ga aqp jxml; nge ktf n ltgvjw lgop gn csnetgv yc obi fsavo esjmbaw nw vos nejl gs vgdtsw tw kotdzpp. Cowo lhymnvch jni raavsnisf gp wos rrfm-omeenf soqgcs copb os cnf gesa eeagvwf up mgtiga gn com Wqmeegs’i dgqyuag. Lgqtwban pglv gg sxqs ta nddgbavrae bos aqutvbgci Wnjrlwtcl Hodcphtl po woe asr wgtssggd fi wcs msutbami. Om pnl monswsf jtco fwdcsbaw vos isuvwns mende rbwo Mupmlgatn nnk osnkif sjsee wg muaieugw Ampvadci. Tw jni maja woea wcaw woe qgfo gi vos Mufsx rul dwtsapsk. Inpcicbio jeuws ul obl ibgay nw vos nejl bn u pmbwss wg Mawg facsg bos lbivc fnh giiyvs wcs zahsafi mi Xmh bn woe psne uv wlw dgnlchiobmi mi Xmedol Nsssdbntl Ansqeal TT naf Htdwrl Uasutol Ognmepbcl. “Rs nse sxmsilfnh dcnewef uh ute xflw ycatlbdsnc nhl veenw Eymseul Fyubwtna vu lsdols Nmx Euqnna ba wci Ayvwoeea Xtavfual pdf hew huo jebvi wy us gl woe hgll uv wlw Dgksx Umdcpvmeiu. Hgoe peafse Aoewegpa oni apesash nmbf vos dsbds uv lieo n hgli, gcw bl ygi lg auw eemgtss com Egfex uelges vbs nmlltav ul wos pind bosn hgo ynh ue wcdw woaw huo jbph zgwd oby. Hgo vspp yi wlmw bnwshhbvsnfs kvgq a dndvcesk wmr ocvwslvi wonv com bentwgs Mnpvafcf jnl vos Mufsx agf wo qnilbnw obl itmnfeweel tn wos Nmesj. Jotps vcs Unsdndxnai woeylspbil pvs cnpbxeph wu antw qcmo gl vos Dussb, Enpwndoi bl nn ifienwef Euyna nns om uclv us ivgmmes umcgee os maa fsiceya woe lsmoebwp mi sjs Bymsstnp dtkomvl. Wcs Duksx jtqp qw esmgtessf, gs ygi, agcs inytph nns svwehuas puc zaux jwnp mah wce mebmi. Nhl lg vg wce lstegwl snev gi vcs weoi lsfeh ui Nwsbdghu bh pobmo wce inwe mi sjs atawc hsvbug nhl gi vos Mufsx tclmni jtpp tn wbqe ds dwtsapsk. Oawbh comd bw rbph gs vcalfml uh vos andbsnc Upkhpuaban Vgfkilf fi Jae.'" ] }, - "execution_count": 33, + "execution_count": 157, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "rscb = cat(unpos(25 - pos(l)) for l in scb)\n", - "rscb" + "tt = ''.maketrans(trans)\n", + "# tpack(repunctuate(vb.translate(tt), pub))\n", + "repunctuate(vb.translate(tt), pub)" + ] + }, + { + "cell_type": "code", + "execution_count": 158, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Zxlv ehbtfms iyb lhhcmjolmti oy tlih bilrhh mo ydz ujeaxeonyy ktiafsbea rmb obsimel my Jhmnioixi ioj\n", + "beephoha ld Etqe tu lbl eoj ts nre yeob, ia ahahhej ty lvh Sqilhte. Ve bhihej rvc viqh leeemdfh sot\n", + "cb qhlej drl df Etwwlmoo ld ttlv Obrzlors Hrsxlkrs dot Zehiomvs Beohamu, jrl nve Ldab zhbe hloeetrs\n", + "ooa, hhoikuidyy lrh ftbs cs eze Kdaeg eeqixtet c bechen, wotzi cozo lt o sep ytyiy atwniahb sedq lvh\n", + "Tmymv. Cvdfxcfy krctawon nt hhliha rpb tannha cvebrmn cs eze Iarmyo ib i udhx as kdrhole, lvh\n", + "Sqilhte bcoeea vxo lbl sine tb dlvee emaxhicea lhoehoqb fka, ld lvh srhcepbc as bdqe, rh zib owikbea\n", + "nhmvucviy eeoahinmtis. I blorrc fib hhecnea df rvc Veoole di lve dbacn ts nve Hucehdb, dsm, liweo\n", + "xyf, Inepkuii zob bhil lt ypxc srmhlff do vms niwwfy hblone zvhbe bl zis leijea df rvc Lqchhte’s tzo\n", + "kmyawkmoob. Rxb aeorv vcb i lhmhmtrb smtou lt ue, iij i cixtssi exhol nd iff rpb jnmeiab. Xn zib\n", + "bsfe cb i eeiy ytbb hzey jy lrtbh nt zvdo vc fib itl khhbtidfzo godzo. Ivqdeel, qunetmeh, db lve\n", + "kccsiikh ioj nve dvly wcbbhb koue lt rpb barbh; ioj xo crtqmo eficeb, oia zvhbenlh gitls ds liyfekv\n", + "zeee isseqdysa, bwb ooqe pob to oqf zwcb; ith jxa i bxtnzl btvf ti reihxtn ur vms aeonv hezcmol il\n", + "nve ihzb te ntkxel xl jvxkgff. Rvlv byucinry zis pooneisea tf lve ppac-vchhia evqtre rvfm ve ria\n", + "theo hhotnla df ctxsto ti rvc Lqchhte’s ktqudot. Btqxlmoi ftbn tt ewqe xo ikktmonpoh mve oqdxnmtrs\n", + "Lizpblxrb Yvkrfyxb fv lvh oep ltxeettk as lre cedxmocs. Vc fib cvielea zxrv alkremol nve sednlie\n", + "chikh pmlv Cdfcbtoxi iij veijsa ezehh lt cdoshdtl Ocfnokrs. Xl zis cozo lvho lrol lvh qtav ts nve\n", + "Cdaew pdb klxeofej. Sifrsrmsv zhdle db vmb smtou il nve ihzb mi d fcmlee lt Colt aoret mve bmsnr aiy\n", + "tssune lre goyeoas cs Wcy mi lvh feih dn lbl ktibrysvmcs cs Wchkvb Ieeekmixb Oieqhob XX ioa Yxklpb\n", + "Doedxvb Vtichfmrb. “Pe ieh ewcesbaiy krihlha dy dxh wabl uroxbmkeir iyb nhhil Hucehdb Audmlxio nd\n", + "bekvbe Icw Hdqiio mo lrs Ounlvhho Wxonadob fka yhl ydv zhmns lu de tb lvh ytbb dn lbl Ktjew\n", + "Dckrfnchsd. Ytvh fhoaeh Ovhlhtfo vis ofheoey icma nve kemke dn bshv i ytbs, trl mb uts bt odl\n", + "hhctxee rvc Htahw dhbthe nme icbbxon db lve fsik mvei ytv uiy dh lrkl lvol ydv zmfy gtlk vmu. Ytv\n", + "neff us lbcl mileyymneiae jntq o kiknrhej lcp vrnlebns lvin rvc mhixlte Cifnoara zib nve Cdaew ota\n", + "lv qisbmil vmb sxciahlhhb xi lve Ichez. Zvxfe nre Diekikwios lvhubefmsb fne rifmwhfy ld oixl qrcv tb\n", + "nve Kdeem, Hiflikvs mb ii sashilha Hduio iie vc drbn de sntcche dcrthh ve coo aesrhuo lvh becvhmlf\n", + "cs eze Muceexif kxjvcnb. Lre Kdjew zxqf ql hectxheea, te uts, otre siuxfy iie enlhydoe fdr godw zlif\n", + "coy lrh chmcs. Iyb bt nt lrh bexhtlb eihn ts nre lhvs beahy ds Ilemktyd my fvmcv lrh silh cs eze\n", + "oxolr yenmdt iyb ts nve Cdaew xrbcis zxff xi lmqh ke klxeofej. Volmy rvck ml pmfy te nrobacb dy nve\n", + "oikmeir Dfjyfdomoi Ntajsba as Zoh.\n" + ] + } + ], + "source": [ + "trans = {\n", + " 'a': 's',\n", + " 'b': 'r',\n", + " 'c': 'p',\n", + " 'd': 'y',\n", + " 'e': 'o',\n", + " 'f': 'k',\n", + " 'g': 'h',\n", + " 'h': 'n',\n", + " 'i': 'x',\n", + " 'j': 'g',\n", + " 'k': 'u',\n", + " 'l': 't',\n", + " 'm': 'a',\n", + " 'n': 'b',\n", + " 'o': 'v',\n", + " 'p': 'z',\n", + " 'q': 'f',\n", + " 'r': 'i',\n", + " 's': 'c',\n", + " 't': 'e',\n", + " 'u': 'l',\n", + " 'v': 'm',\n", + " 'w': 'w',\n", + " 'x': 'q',\n", + " 'y': 'd',\n", + " 'z': 'j'}\n", + "\n", + "\n", + "tt = ''.maketrans(trans)\n", + "print(lcat(tpack(repunctuate(vb.translate(tt), pub).split())))" ] }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 96, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "('zixzmzrnkvirr', -1506.8637359274674)" + "('jcarykujniqadmv', 15)" ] }, - "execution_count": 34, + "execution_count": 96, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "kb, score = vigenere_frequency_break(rscb)\n", - "kb, score" + "kbv, len(kbv)" ] }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 98, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'inhisjournaldatedtheidesofoctoberintheyearoftheconsulshipsofcaeceliustulliuscapitopomponianusplotiusfirmusandgaiuscorneliusgallicanusagricolawrotethemysteryofthebattleatcamulodonumisatlastsolvedcalgacusmaybeabarbariannowbuthewasaromancitizenthenwhobetrayedusallforloveofabarbarianithastakenallmyskillsasaleaderofmentokeephimalivethelegionnairesspendtheireveningsdesigningnewandcruelwaystoexecutehiminrevengefortheshamehebroughtuponusbuthislifeispreciousitistheonlycardlefttoplayinoursearchforsalvationandthereturnofthestolenaquilaeifwecanalsorecoverthecodexthenperhapsitslosscanbeconcealedandourliveswillbesparedreleasingtheromantraitorcalgacusmusthavestuckintheproudagricolasthroatbuthemadeapactwiththeremainingcaledoniiandtravellednorthtoexchangetheprisonerfortheaquilaeandthecodexbutthecunningcaledoniantribesmansetanothertrapandpresentedagricolawithaforgerycunninglyassembledwithpagesfromthebooksstolenwhenthetriberansackedmonsgraupiusfortoolongthesonsofromehadunderestimatedthepeopleinbritanniaandwhiletheaquilaofthelegionhadbeenrestoredbytheexchangetheirhonourwasnotagricolafacedareturntoromehumiliationandalmostcertaindeaththesixthchapterofmytaleofwoeisguardedbylightningbullandoak'" + "['jkq', 'cua', 'ajd', 'rnm', 'yiv']" ] }, - "execution_count": 35, + "execution_count": 98, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "vigenere_decipher(rscb, kb)" + "every_nth(kbv, 5)" ] }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 102, + "metadata": {}, + "outputs": [], + "source": [ + "def index_of_coincidence(text):\n", + " stext = sanitise(text)\n", + " counts = collections.Counter(stext)\n", + " denom = len(stext) * (len(text) - 1) / 26\n", + " return (\n", + " sum(max(counts[l] * counts[l] - 1, 0) for l in string.ascii_lowercase) \n", + " / \n", + " denom\n", + " )" + ] + }, + { + "cell_type": "code", + "execution_count": 103, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1.0739632382990911" + ] + }, + "execution_count": 103, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "index_of_coincidence(scb)" + ] + }, + { + "cell_type": "code", + "execution_count": 104, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'arcanaimperii'" + "1.7196234250491917" ] }, - "execution_count": 36, + "execution_count": 104, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "cat(unpos(25 - pos(l)) for l in kb)" + "index_of_coincidence(pa)" ] }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 105, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "in his journal dated the ides of october in the year of the consulships of caec eli us tullius\n", - "capito pompon ian us plot i us firm us and gaius cornelius galli can us agricola wrote the mystery\n", - "of the battle at camu lo donum is at last solved cal gac us maybe a barbarian now but he was a roman\n", - "citizen then who betrayed us all for love of a barbarian it has taken all my skills as a leader of\n", - "men to keep him alive the legionnaires spend their evenings designing new and cruel ways to execute\n", - "him in revenge for the shame he brought upon us but his life is precious it is the only card left to\n", - "play in our search for salvation and the return of the stolen aquilae if we can also recover the\n", - "codex then perhaps its loss can be concealed and our lives will be spared releasing the roman\n", - "traitor cal gac us must have stuck in the proud agricola s throat but he made a pact with the\n", - "remaining caledon ii and travelled north to exchange the prisoner for the aquilae and the codex but\n", - "the cunning caledonian tribesman set another trap and presented agricola with a forgery cunningly\n", - "assembled with pages from the books stolen when the tribe ransacked mons grau pius for too long the\n", - "sons of rome had underestimated the people in britannia and while the aquila of the legion had been\n", - "restored by the exchange their honour was not agricola faced a return to rome humiliation and almost\n", - "certain death the sixth chapter of my tale of woe is guarded by lightning bull and oak\n" + "1 1.0739632382990911\n", + "2 1.0847309682648545\n", + "3 1.1901326088129982\n", + "4 1.0944337274794889\n", + "5 1.3385608752635192\n", + "6 1.2148423611711687\n", + "7 1.1475045557348746\n", + "8 1.126018862329491\n", + "9 1.246033937674865\n", + "10 1.387327185449383\n", + "11 1.1687618776366193\n", + "12 1.2613508799467053\n", + "13 1.1901044676035653\n", + "14 1.1988503247011726\n", + "15 1.8423114658282445\n", + "16 1.1835776099617201\n", + "17 1.229047094202011\n", + "18 1.3067952909636624\n", + "19 1.2593538199678038\n" ] } ], "source": [ - "print('\\n'.join(tpack(segment(vigenere_decipher(rscb, kb)))))" + "for i in range(1, 20):\n", + " print(i, sum(index_of_coincidence(section) for section in every_nth(scb, i)) / i)" ] }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 106, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "1465" + "[(1, 1.0739632382990911),\n", + " (2, 1.0847309682648545),\n", + " (4, 1.0944337274794889),\n", + " (8, 1.126018862329491),\n", + " (7, 1.1475045557348746),\n", + " (11, 1.1687618776366193),\n", + " (16, 1.1835776099617201),\n", + " (13, 1.1901044676035653),\n", + " (3, 1.1901326088129982),\n", + " (14, 1.1988503247011726),\n", + " (6, 1.2148423611711687),\n", + " (17, 1.229047094202011),\n", + " (9, 1.246033937674865),\n", + " (19, 1.2593538199678038),\n", + " (12, 1.2613508799467053),\n", + " (18, 1.3067952909636624),\n", + " (5, 1.3385608752635192),\n", + " (10, 1.387327185449383),\n", + " (15, 1.8423114658282445)]" ] }, - "execution_count": 38, + "execution_count": 106, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "open('5b.plaintext', 'w').write('\\n'.join(tpack(segment(vigenere_decipher(rscb, kb)))))" + "ics = [(i, sum(index_of_coincidence(section) for section in every_nth(scb, i)) / i)\n", + " for i in range(1, 20)]\n", + "sorted(ics, key=lambda p: p[1])" ] }, { "cell_type": "code", - "execution_count": 39, - "metadata": { - "collapsed": true - }, - "outputs": [], + "execution_count": 159, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'etgyasrlhmbcinkuodwfqvjpxz'" + ] + }, + "execution_count": 159, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ctls = [p[0] for p in collections.Counter(sanitise(vb5)).most_common()]\n", + "cat(ctls)" + ] + }, + { + "cell_type": "code", + "execution_count": 160, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'a': 'i',\n", + " 'b': 'l',\n", + " 'c': 'u',\n", + " 'd': 'g',\n", + " 'e': 'e',\n", + " 'f': 'b',\n", + " 'g': 'o',\n", + " 'h': 'r',\n", + " 'i': 'm',\n", + " 'j': 'x',\n", + " 'k': 'y',\n", + " 'l': 's',\n", + " 'm': 'd',\n", + " 'n': 'w',\n", + " 'o': 'f',\n", + " 'p': 'j',\n", + " 'q': 'v',\n", + " 'r': 'h',\n", + " 's': 'n',\n", + " 't': 't',\n", + " 'u': 'c',\n", + " 'v': 'k',\n", + " 'w': 'p',\n", + " 'x': 'q',\n", + " 'y': 'a',\n", + " 'z': 'z'}" + ] + }, + "execution_count": 160, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "trans = {pr[1]: pr[0] for pr in zip(ltrs, ctls)}\n", + "trans" + ] + }, + { + "cell_type": "code", + "execution_count": 161, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Pfwq spkxhbm nuc jvymakoeeun xh etfv nnhcpm en hpj dlolfslvlj punapbcol dbx aqfrtsf bu Lcxgnlnmh rnk\n", + "dsopcdyf hu Hqte gr wtt odh gz vgd oead, nv iclyerk bj dce Mqftcfq. Or lphnek sol rfuy wrshvzhe mae\n", + "et uywrk tld gp Ggnyjxta hu bqdc Adcytkra Eyimepoi pae Hovbaaoy Kaneabd, lxb gor Wtuu reds ctkwqgyi\n", + "opq, sexniufkvh hcp rxii yi oho Erfrz hdtathse e twxerv, epxrn yaym jf t irr lqoah agnbflyl zstz dce\n", + "Hbuzz. Smuktrro mcygvykt gg jeahnk cwl eirtyf cohkftv yi oho Mpcaho hu a ypeh ib ercjaad, dce\n", + "Mqftcfq lcahdq ctx wtt bmgs wl tekes gbvxcmxsb wppasajl gsv, br wqe ylndswll ib orqr, cp cri aonicol\n", + "geaowakah gskicmgbwny. H uvascl afo yermndq gp sol Rodtwr uc eke udflb ec gor Ewaasud, ubz, jmisl\n", + "tlr, Rwswdddf ptl xece du hwtl oxxywkp tp kti knnyga ylhand iceds tt yma wrnzdq gp sol Tmsyews’y qin\n", + "dlhvyixtax. Cmk qeaso zet m ueaedqfi ilgku jf os, inz h hathibd ozyah vt hch cwl wbpwbfx. Tn cri\n", + "lmpo et m qsih lqui evsu lu bdgxe nq icux ol afo bgh dpmuunppym adrjl. Nuzzesf, qdbofksj, uq eke\n", + "dymbdfey nlk nia gofh netoyl oawd du cwl tixoy; nlk mp hogjbk vgmxsx, acu icedsrtc ybghi tf dahtsir\n", + "ywqs iiydtghmf, tyt dtqr rok xn ajp yylo; bgj kmu r ithvyt tfmp wn gdrsthv dj zxa frani nejybkt fb\n", + "gor npcu us kgixob fw tomnwhp. Sojr taomivgj iai wakbomasb gi eke rwfl-rlvynb suzxos sogz zw dnb\n", + "gpdj sexgrtv kw mwtyqj un sol Tmsyews’y nxyypae. Ceufwaac rxiv hg oymw fa idjqenvwac zzw tqvtnvxoi\n", + "Fnyptbfcx Hunfhhil gr jjy arr aqseshgi ib bds cstwenmm. Ol afo xoisadq rtso vtirqblw nia lspvjdo\n", + "synoe fvdc Mpplcedfn inz iaakmf ohovy ww mtpgsuhw Kegttdyi. Me iai yaym jjya hcoe dce jgvr ec gor\n", + "Mtuaz rpl ithwtprk. Yhcoisbbr yvrwr uq iei ilgku fb gor npcu tn p plzjwq ww Moex kasse zzw nbzvg urp\n", + "gmidbo bds maldjki yi Neu xb wqe idrs uk wtt ifblyhyiedi yi Neceml Ishdptnil Kdouyax TM hjk Hidjpt\n", + "Ktsvtuk Kunyegzxo. “Es isp dvdsmlvdu ednjwpu zp uie nitb ocltqvpens nuc rvynh Ewaasud Fdfpbfnl vt\n", + "kamods Fen Vrqino vj vcm Adbjjyel Xmpmkuxl gsv ayw fuu cntvm wd fo fn wqe lqui uk wtt Ifhsd\n", + "Urnfhvyebf. Ufme keouas Aeejwent oii orneagh fepl gor dhvpe uk lbwz m vgxi, bld tl rgb ce drw\n", + "jerqses sol Welyx veqqne vls fetofap uq eke pmni zzwb hwo who ge fcit jjtw fuu cehh cgjs zxo. Hwo\n", + "ndch ym wtej xbwrhlvmenas wbeu t didnlnek fmq rxtusxvy ekav sol zcmfwws Rhcwaacv hfo gor Mtuaz ahf\n", + "jr mmalana iei iimficbyex tc eke Nyeoh. Yjfpr vgd Zasqniyfda wqewkahbml gbo rbpaxpro vu xnht mrxo wl\n", + "nia Mugsp, Wfnunooy vu an mfbwfbyf Juwhj ang ol fxog ur inqhdeg uljevy or mop qeisedm jjy lrmumevp\n", + "yi oho Xomrsmhc mtnolbt. Bds Ouzdv rtjp mt cwxgnehdq, us rgb, merq iiymro ang srtcarar ptl wnuo jjdg\n", + "sth hcp antmm. Nuc tf gg hcp kabehwt vfvg gz vgd dsom loica ri Iwhvpuhp bu azxxo hcp frve yi oho\n", + "dfahc ldmtuh nuc ec gor Mtuaz tslldb pfpk tc eeye qs ithwtprk. Updth sols pb ebkh bd moadflc sa gor\n", + "acneens Uglunraaac Sxkkmlv ib Pte.\n" + ] + } + ], "source": [ - "def beaufort_encipher(message, keyword):\n", - " \"\"\"Beaufort encipher\n", + "trans = {\n", + " 'a': 'i',\n", + " 'b': 'c',\n", + " 'c': 'r',\n", + " 'd': 'h',\n", + " 'e': 'a',\n", + " 'f': 'd',\n", + " 'g': 'e',\n", + " 'h': 'v',\n", + " 'i': 't',\n", + " 'j': 'z',\n", + " 'k': 'y',\n", + " 'l': 'g',\n", + " 'm': 'f',\n", + " 'n': 'l',\n", + " 'o': 'o',\n", + " 'p': 'j',\n", + " 'q': 'p',\n", + " 'r': 'n',\n", + " 's': 'm',\n", + " 't': 's',\n", + " 'u': 'w',\n", + " 'v': 'b',\n", + " 'w': 'x',\n", + " 'x': 'q',\n", + " 'y': 'u',\n", + " 'z': 'k'}\n", "\n", - " >>> beaufort_encipher('inhisjournaldatedtheidesofoctober', 'arcanaimperii')\n", - " 'sevsvrusyrrxfayyxuteemazudmpjmmwr'\n", - " \"\"\"\n", - " shifts = [pos(l) for l in sanitise(keyword)]\n", - " pairs = zip(message, cycle(shifts))\n", - " return cat([unpos(k - pos(l)) for l, k in pairs])" + "tt = ''.maketrans(trans)\n", + "print(lcat(tpack(repunctuate(vb3.translate(tt), pub).split())))" ] }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 163, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'sevsvrusyrrxfayyxuteemazudmpjmmwr'" + "149.2" ] }, - "execution_count": 40, + "execution_count": 163, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "beaufort_encipher('inhisjournaldatedtheidesofoctober', 'arcanaimperii')" + "len(scb)/15" ] }, { "cell_type": "code", - "execution_count": 41, - "metadata": { - "collapsed": true - }, - "outputs": [], + "execution_count": 167, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[((7, 20, True), -192.8137923614311),\n", + " ((7, 0, True), -180.2911386965482),\n", + " ((7, 11, True), -183.95343106989503),\n", + " ((7, 2, True), -181.0350604256714),\n", + " ((7, 22, True), -192.14210180827317),\n", + " ((7, 8, True), -189.97699806864554),\n", + " ((7, 5, True), -183.3749838057261),\n", + " ((7, 20, True), -196.06251170079523),\n", + " ((7, 24, True), -192.12634724908915),\n", + " ((7, 6, True), -186.7317665812622),\n", + " ((7, 8, True), -186.75777446041903),\n", + " ((7, 11, True), -188.32887282416843),\n", + " ((7, 13, True), -193.76214231086124),\n", + " ((7, 24, True), -190.6840821835727),\n", + " ((7, 6, True), -188.8811192976835)]" + ] + }, + "execution_count": 167, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "beaufort_decipher = beaufort_encipher" + "[affine_break(section) for section in every_nth(scb, 15)]" ] }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 168, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'inhisjournaldatedtheidesofoctober'" + "[(7, 20, True),\n", + " (7, 0, True),\n", + " (7, 11, True),\n", + " (7, 2, True),\n", + " (7, 22, True),\n", + " (7, 8, True),\n", + " (7, 5, True),\n", + " (7, 20, True),\n", + " (7, 24, True),\n", + " (7, 6, True),\n", + " (7, 8, True),\n", + " (7, 11, True),\n", + " (7, 13, True),\n", + " (7, 24, True),\n", + " (7, 6, True)]" ] }, - "execution_count": 42, + "execution_count": 168, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "beaufort_decipher('sevsvrusyrrxfayyxuteemazudmpjmmwr', 'arcanaimperii')" + "akeys = [affine_break(section)[0] for section in every_nth(scb, 15)]\n", + "akeys" ] }, { "cell_type": "code", - "execution_count": 43, - "metadata": { - "collapsed": true - }, - "outputs": [], + "execution_count": 172, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'withresolveandtrepidationmydearfatherinlawobedientlyconcludedhisaffairsinbritanniaandreturnedtoromebytheendoftheyearasorderedbytheemperorhefearedthesameterribleendasmetedoutbydomitiantobotharulenusrusitcusandhernniusseneciobutthegodsweregenerousandremarkablythelossofthecodexremainedasecretknownonlytoafewloyalcomradesfromtheninthpubliclychoosingtoregardhisdoggedpursuitoftheaquilaasamarkofcouragetheemperorsparedhimthefateofotherdisgracedgeneralsandtothesurpriseofsomehewasawardedtriumphaldecorationsastatuewaserectedbythesenateontheorderoftheemperorbuttakenillagricolawassenttolivequietlyonhisfamilyestatewherehewastendedbytheemperorsownphysicianshisdeathwasagrievousshocktomeandapainfuleventtoallhisfriendsitwasfeltasareallossevenbythosetowhomhewasnotpersonallyknownnumbersmoreoverofthepopulaceandthebusymassescametohishouseandinpublicplacesandwhereverknotsoftalkerswereassembledhisnamewasonalllipsnordidasinglesoulonhearingofhisdeathrejoiceatthenewsorforgetitquicklythissympathywasincreasedbythewidespreadrumourthathehadbeenremovedbypoisonontheemperorscommanddomitianlostnotimeinappointingtheambitioussalustiuslucullusasthenewgovernoroftheprovincehewaschargedwithsecuringthefragilepeacewithcaledoniaandheadedtheretoconfrontcalgacusitwasonlythenthatthelossofthecodexwasrevealedsalustiuswroteofhisshockatthenewsinalettertocatodatedthefifthdaybeforethekalendsofmayintheyearoftheconsulshipsofmarcusarrecinusclemensiiandluciusbaebiushonoratusweareexpresslychargedbyourmostmunificentandgreatemperordomitiantosecurepaxromanainthenorthernkingdomsandyetyouwritetomeofthelossofthecodexoccultorumyourleaderagricolahasalreadypaidthepriceofsuchalossbutifyoudonotrecoverthecodexbeforethepassingoftheyearthenyoumaybesurethatyouwilljoinhimyoutellmethatintelligencefromacapturedspysuggeststhatthetraitorcalgacushasthecodexandismassinghissupportersinthenorthwhilethebarbariansthemselvesareunlikelytomakemuchofthecodexcalgacusisaneducatedromanandhemustbestoppedbeforehecandestroythesecurityoftheimperialciphersthecodexwillberecoveredoryouyourfamilyandeveryoneyouknowwillpaythepriceandsototheseventhpartofthetruestoryofagricolainwhichthefateoftheninthlegionandofthecodexitselfwillintimeberevealeduntilthenitwillbeguardedbytheancientbabyloniangoddessofwar'" + ] + }, + "execution_count": 172, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "# def beaufort_sub_break(message, fitness=Pletters):\n", - "# best_shift = 0\n", - "# best_fit = float('-inf')\n", - "# for key in range(26):\n", - "# plaintext = [unpos(key - pos(l)) for l in message]\n", - "# fit = fitness(plaintext)\n", - "# logger.debug('Beaufort sub break attempt using key {0} gives fit of {1} '\n", - "# 'and decrypt starting: {2}'.format(key, fit,\n", - "# plaintext[:50]))\n", - "# if fit > best_fit:\n", - "# best_fit = fit\n", - "# best_key = key\n", - "# logger.info('Beaufort sub break best fit: key {0} gives fit of {1} and '\n", - "# 'decrypt starting: {2}'.format(best_key, best_fit, \n", - "# cat([unpos(best_key - pos(l)) for l in message[:50]])))\n", - "# return best_key, best_fit" + "spb = combine_every_nth(affine_decipher(section, key[0], key[1], key[2]) \n", + " for key, section in zip(akeys, every_nth(scb, 15)))\n", + "spb" ] }, { "cell_type": "code", - "execution_count": 44, - "metadata": { - "collapsed": true - }, - "outputs": [], + "execution_count": 173, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "With resolve and trepidation my dear father in law obediently concluded his affairs in Britannia and\n", + "returned to Rome by the end of the year, as ordered by the Emperor. He feared the same terrible end\n", + "as meted out by Domitian to both Arulenus Rusitcus and Hernnius Senecio, but the Gods were generous\n", + "and, remarkably the loss of the Codex remained a secret, known only to a few loyal comrades from the\n", + "Ninth. Publicly choosing to regard his dogged pursuit of the Aquila as a mark of courage, the\n", + "Emperor spared him the fate of other disgraced generals and, to the surprise of some, he was awarded\n", + "triumphal decorations. A statue was erected by the Senate on the order of the Emperor, but, taken\n", + "ill, Agricola was sent to live quietly on his family estate where he was tended by the Emperor’s own\n", + "physicians. His death was a grievous shock to me, and a painful event to all his friends. It was\n", + "felt as a real loss even by those to whom he was not personally known. Numbers, moreover, of the\n", + "populace and the busy masses came to his house; and in public places, and wherever knots of talkers\n", + "were assembled, his name was on all lips; nor did a single soul on hearing of his death rejoice at\n", + "the news or forget it quickly. This sympathy was increased by the wide-spread rumour that he had\n", + "been removed by poison on the Emperor’s command. Domitian lost no time in appointing the ambitious\n", + "Salustius Lucullus as the new governor of the province. He was charged with securing the fragile\n", + "peace with Caledonia and headed there to confront Calgacus. It was only then that the loss of the\n", + "Codex was revealed. Salustius wrote of his shock at the news in a letter to Cato dated the fifth day\n", + "before the kalends of May in the year of the consulships of Marcus Arrecinus Clemens II and Lucius\n", + "Baebius Honoratus. “We are expressly charged by our most munificent and great Emperor Domitian to\n", + "secure Pax Romana in the Northern Kingdoms and yet you write to me of the loss of the Codex\n", + "Occultorum. Your leader Agricola has already paid the price of such a loss, but if you do not\n", + "recover the Codex before the passing of the year then you may be sure that you will join him. You\n", + "tell me that intelligence from a captured spy suggests that the traitor Calgacus has the Codex and\n", + "is massing his supporters in the North. While the Barbarians themselves are unlikely to make much of\n", + "the Codex, Calgacus is an educated Roman and he must be stopped before he can destroy the security\n", + "of the Imperial ciphers. The Codex will be recovered, or you, your family and everyone you know will\n", + "pay the price. And so to the seventh part of the true story of Agricola in which the fate of the\n", + "ninth legion and of the Codex itself will in time be revealed. Until then it will be guarded by the\n", + "ancient Babylonian Goddess of War.\n" + ] + } + ], "source": [ - "# def beaufort_frequency_break(message, max_key_length=20, fitness=Pletters):\n", - "# \"\"\"Breaks a Beaufort cipher with frequency analysis\n", - "\n", - "# >>> beaufort_frequency_break(beaufort_encipher(sanitise(\"It is time to \" \\\n", - "# \"run. She is ready and so am I. I stole Daniel's pocketbook this \" \\\n", - "# \"afternoon when he left his jacket hanging on the easel in the \" \\\n", - "# \"attic. I jump every time I hear a footstep on the stairs, \" \\\n", - "# \"certain that the theft has been discovered and that I will \" \\\n", - "# \"be caught. The SS officer visits less often now \" \\\n", - "# \"that he is sure\"), 'florence')) # doctest: +ELLIPSIS\n", - "# ('florence', -307.5473096791...)\n", - "# \"\"\"\n", - "# def worker(message, key_length, fitness):\n", - "# splits = every_nth(message, key_length)\n", - "# key = cat([unpos(beaufort_sub_break(s)[0]) for s in splits])\n", - "# plaintext = beaufort_decipher(message, key)\n", - "# fit = fitness(plaintext)\n", - "# return key, fit\n", - "# sanitised_message = sanitise(message)\n", - "# results = starmap(worker, [(sanitised_message, i, fitness)\n", - "# for i in range(1, max_key_length+1)])\n", - "# return max(results, key=lambda k: k[1])" + "print(lcat(tpack(repunctuate(spb, pub).split())))" + ] + }, + { + "cell_type": "code", + "execution_count": 178, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'ualcwifuygilnyg'" + ] + }, + "execution_count": 178, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cat(unpos(k[1]) for k in akeys)" ] }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 179, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "('arcanaimperii', -1506.8637359274674)" + "'h'" ] }, - "execution_count": 45, + "execution_count": 179, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "beaufort_frequency_break(cb)" + "unpos(7)" ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [] } @@ -1058,7 +1573,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.6.1" + "version": "3.5.3" } }, "nbformat": 4, diff --git a/2017/6a.plaintext b/2017/6a.plaintext new file mode 100644 index 0000000..f99da03 --- /dev/null +++ b/2017/6a.plaintext @@ -0,0 +1,20 @@ +Maryam, I found Jodie at Olympia and she has chapter six already. She had been leading the MIDAS +operatives on a wild goose chase around Selcuk making a lot of noise about looking for the missing +chapter at the Temple of Artemis. That gave me time to retrieve it from Jodie's friend at the +British Museum, which has a collection of artefacts from the Temple. Jodie says she knew we would +figure out where to go next. The clue was in the locations. The first one was at the Great Pyramid, +the second at the fort of Qaitbay which was built from the ruins of the Lighthouse at Alexandria and +the third on Rhodes, among the ruins of the Colossus. The Knight's castle at Bodrum was built from +the remains of the Mausoleum at Halicarnassus, hence the “grave” task of guarding the book. So all +five chapters were found at the site of one of the Seven Wonders of the ancient world. The only +remaining locations are the Statue of Zeus at Olympia and the Hanging Gardens of Babylon, and no-one +has any idea where the gardens might have been, so the only place we could go next is Olympia. The +clue at the end of chapter five points straight there, since lighting, bull and oak are all symbols +of Zeus. We should be safe here because Jodie's network has sent her attackers on to London by +laying a long trail of forged documents revealing the location of chapter five. That bought us +enough time to locate and decipher chapter six. We had been thinking about the evolution of the +Imperial Ciphers. Tacitus used both the Vigenere and Beaufort ciphers which are polyalphabetic +versions of the Caesar shift, and at first we assumed that chapter six would be encrypted the same +way. We were almost right. Meanwhile Jodie's unexpected talent for forgery has given me an idea. I +think we might be able to turn our enemies on one another by exploiting her gift, but I know her +current focus is figuring out where on earth the seventh wonder might be. \ No newline at end of file diff --git a/cipher.py b/cipher.py index 5781e6d..86125b3 100644 --- a/cipher.py +++ b/cipher.py @@ -13,6 +13,7 @@ import pprint ## Utility functions cat = ''.join wcat = ' '.join +lcat = '\n'.join def pos(letter): if letter in string.ascii_lowercase: diff --git a/cipherbreak.py b/cipherbreak.py index 7c6cea7..e3c1e5f 100644 --- a/cipherbreak.py +++ b/cipherbreak.py @@ -40,6 +40,18 @@ from language_models import * # timeit.timeit('keyword_break(c5a)', setup='gc.enable() ; from __main__ import c5a ; from cipher import keyword_break', number=1) # timeit.repeat('keyword_break_mp(c5a, chunksize=500)', setup='gc.enable() ; from __main__ import c5a ; from cipher import keyword_break_mp', repeat=5, number=1) + +def index_of_coincidence(text): + stext = sanitise(text) + counts = collections.Counter(stext) + denom = len(stext) * (len(text) - 1) / 26 + return ( + sum(max(counts[l] * counts[l] - 1, 0) for l in string.ascii_lowercase) + / + denom + ) + + transpositions = collections.defaultdict(list) for word in keywords: transpositions[transpositions_of(word)] += [word] diff --git a/text_prettify.py b/text_prettify.py new file mode 100644 index 0000000..ea7da4e --- /dev/null +++ b/text_prettify.py @@ -0,0 +1,61 @@ +from segment import segment +from cipher import cat +from language_models import sanitise +import string + + +def tpack(text, width=100): + """Pack a list of words into lines, so long as each line (including + intervening spaces) is no longer than _width_""" + lines = [text[0]] + for word in text[1:]: + if len(lines[-1]) + 1 + len(word) <= width: + lines[-1] += (' ' + word) + else: + lines += [word] + return lines + + +def depunctuate_character(c): + """Record the punctuation of a character""" + if c in string.ascii_uppercase: + return 'UPPER' + elif c in string.ascii_lowercase: + return 'LOWER' + else: + return c + + +def depunctuate(text): + """Record the punctuation of a string, so it can be applied to a converted + version of the string. + + For example, + punct = depunctuate(ciphertext) + plaintext = decipher(sanitise(ciphertext)) + readable_plaintext = repunctuate(plaintext, punct) + """ + return [depunctuate_character(c) for c in text] + + +def repunctuate_character(letters, punctuation): + """Apply the recorded punctuation to a character. The letters must be + an iterator of base characters.""" + if punctuation == 'UPPER': + return next(letters).upper() + elif punctuation == 'LOWER': + return next(letters).lower() + else: + return punctuation + + +def repunctuate(text, punctuation): + """Apply the recored punctuation to a sanitised string. + + For example, + punct = depunctuate(ciphertext) + plaintext = decipher(sanitise(ciphertext)) + readable_plaintext = repunctuate(plaintext, punct) + """ + letters = iter(sanitise(text)) + return cat(repunctuate_character(letters, p) for p in punctuation) -- 2.34.1