X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=2015%2F2015-challenge6.ipynb;fp=2015%2F2015-challenge6.ipynb;h=33b5b7baa043aa3fe168f9829656dc0a58c8cf4d;hb=1350633e419f802975c773db8de86e3de49ea7fd;hp=e01a50cd8efe5644638cc305399f70a80c440507;hpb=df271527a6e3e4d10da9f9be3d1e9ebea9171493;p=cipher-tools.git diff --git a/2015/2015-challenge6.ipynb b/2015/2015-challenge6.ipynb index e01a50c..33b5b7b 100644 --- a/2015/2015-challenge6.ipynb +++ b/2015/2015-challenge6.ipynb @@ -3,9 +3,7 @@ { "cell_type": "code", "execution_count": 1, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "import os,sys,inspect\n", @@ -16,7 +14,10 @@ "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "\n", - "from cipherbreak import *\n", + "from cipher.keyword_cipher import *\n", + "from cipher.vigenere import *\n", + "from support.utilities import *\n", + "from support.text_prettify import *\n", "\n", "c6a = sanitise(open('6a.ciphertext').read())\n", "c6b = sanitise(open('6b.ciphertext').read())" @@ -25,9 +26,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -48,9 +47,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -67,9 +64,7 @@ { "cell_type": "code", "execution_count": 4, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -89,9 +84,7 @@ { "cell_type": "code", "execution_count": 5, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -116,9 +109,7 @@ { "cell_type": "code", "execution_count": 6, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -138,9 +129,7 @@ { "cell_type": "code", "execution_count": 7, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -161,9 +150,7 @@ { "cell_type": "code", "execution_count": 8, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -183,9 +170,7 @@ { "cell_type": "code", "execution_count": 9, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -202,9 +187,7 @@ { "cell_type": "code", "execution_count": 10, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -225,9 +208,7 @@ { "cell_type": "code", "execution_count": 11, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -241,12 +222,50 @@ "print(' '.join(segment(sanitise(vigenere_decipher(sanitise(c6b), key_b)))))" ] }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "('railfencstuvwxyzbdghjkmopq', -5965.858211099189)" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "simulated_annealing_break(c6a, fitness=Ptrigrams)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'charlieitwasthetypoinratilinesthatgaveitawayitappearedbothinthetypedmessageswepickedupandinthetranscriptoftheradiomessageprettyunlikelycoincidencesoifigureyourjuniorcipherclerkwasinvolvedmightbeworthcheckingherbackgroundandbankaccountsthatisallimeantwhenisaidthesourcewasclosetohomebutthinkingaboutitiamnotsureitmakessensetothinkshewasthesourcethemessagesstillkeepcomingandiamguessingthatshehasgonesotheremustbesomeothersourceforourintelligencesomethingisbotheringmeaboutthetoneofthemessageswhydoesourantagonistkeeptauntingusaboutouralliesitisnotlikethethingswearebeingaskedtobidforarethingswearelikelytohidefromoneanotherafterallanywayifollowedoneofourfrenchcolleaguestofriedrichstrasseandwatchedhertrytopickupthekeyfromlockerseemstohavebeenaconicouldntclearlyseewhatwasgoingonbutshedidntseemtobeabletoopenlockerandleftobviouslyupsetaftershehadgoneitookalookatlockerithasafalsebacksoiamguessingthemoneywastakenbutnothingprovidedinexchangecouldyoudigaroundwithyourcontactsinthebritishandrussianembassiesandseeiftheyaregettingthesamesortofcommunicationsmaybeyoucouldwarnthembythewaydiealchemistenprojectwasthecodenameforthenaziatombombeffortihadaruninwiththemduringthewarwhenweweretryingtokeeptheirhandsofftheheavywatersupplyrememberthebombinginvemorkthatwasusorratherournordicalliesanywayitisstilltopsecretsothefactourprotagonistknowsaboutitissignificantisuspectthekeytothiswholemysteryliesintheiridentityifweknewwhotheywereworkingforwemightbeabletofigureoutwhattheyareuptoonelastthingactingonahunchitookalookatsomeofthefrenchdeaddropsafterthefriedrichstrasseincidentandfoundtheattachedcommunicationihaventhadtimetocrackitbutithinkitmaybeavigenereagainbutihaventhadachancetotrybabbagestrickonityetgiveittoyourblackchamberandseewhattheycanmakeofitallthebestharry'" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "keyword_decipher(c6a, 'railfencstuvwxyzbdghjkmopq')" + ] + }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [] } @@ -267,9 +286,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.4.3" + "version": "3.6.3" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 }