{
"cell_type": "code",
"execution_count": 1,
- "metadata": {
- "collapsed": false
- },
+ "metadata": {},
"outputs": [],
"source": [
"import os,sys,inspect\n",
"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())"
{
"cell_type": "code",
"execution_count": 2,
- "metadata": {
- "collapsed": false
- },
+ "metadata": {},
"outputs": [
{
"data": {
{
"cell_type": "code",
"execution_count": 3,
- "metadata": {
- "collapsed": false
- },
+ "metadata": {},
"outputs": [
{
"name": "stdout",
{
"cell_type": "code",
"execution_count": 4,
- "metadata": {
- "collapsed": false
- },
+ "metadata": {},
"outputs": [
{
"data": {
{
"cell_type": "code",
"execution_count": 5,
- "metadata": {
- "collapsed": false
- },
+ "metadata": {},
"outputs": [
{
"data": {
{
"cell_type": "code",
"execution_count": 6,
- "metadata": {
- "collapsed": false
- },
+ "metadata": {},
"outputs": [
{
"data": {
{
"cell_type": "code",
"execution_count": 7,
- "metadata": {
- "collapsed": false
- },
+ "metadata": {},
"outputs": [
{
"data": {
{
"cell_type": "code",
"execution_count": 8,
- "metadata": {
- "collapsed": false
- },
+ "metadata": {},
"outputs": [
{
"data": {
{
"cell_type": "code",
"execution_count": 9,
- "metadata": {
- "collapsed": false
- },
+ "metadata": {},
"outputs": [
{
"name": "stdout",
{
"cell_type": "code",
"execution_count": 10,
- "metadata": {
- "collapsed": false
- },
+ "metadata": {},
"outputs": [
{
"data": {
{
"cell_type": "code",
"execution_count": 11,
- "metadata": {
- "collapsed": false
- },
+ "metadata": {},
"outputs": [
{
"name": "stdout",
"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": []
}
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.4.3"
+ "version": "3.6.3"
}
},
"nbformat": 4,
- "nbformat_minor": 0
+ "nbformat_minor": 1
}