{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import os,sys,inspect\n", "currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))\n", "parentdir = os.path.dirname(currentdir)\n", "sys.path.insert(0,parentdir) \n", "\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "\n", "from cipher.caesar import *\n", "from support.text_prettify import *\n", "\n", "c1a = open('1a.ciphertext').read()\n", "c1b = open('1b.ciphertext').read()" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(21, -1118.7224542255447)" ] }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "key_a, score = caesar_break(c1a)\n", "key_a, score" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "MARYAM,\n", "IT IS GREAT TO HEAR FROM YOU. WE DID PICK UP SOME CHATTER A COUPLE OF MONTHS AGO AND J WAS MENTIONED THERE TOO, SO WE ALREADY HAVE A FILE ON HER. HER NAME IS JODIE AND SHE WORKS AS LIAISON BETWEEN THE BRITISH LIBRARY AND THE BRITISH MUSEUM, RESEARCHING LINKS BETWEEN ARTEFACTS AND IMPERIAL ROMAN TEXTS, SO THAT TIES IN WITH THE INTELLIGENCE YOU HAVE BEEN RECEIVING. NOTHING SUGGESTS THAT SHE HAS BEEN INVOLVED IN ANYTHING SHADY AND SHE HAS HELPED WITH SEVERAL INSURANCE FRAUD CASES. SHE HAS AN INTERESTING BACKGROUND. SHE DID A PHD ON HUMAN MIGRATION STUDIES, MAINLY MATHEMATICAL MODELLING, THEN MOVED ON TO STUDY KNOWLEDGE MIGRATION WHICH GOT HER INTO THE BIBLIOPHILE CIRCUIT. AFTER GRADUATING SHE SPENT SOME TIME WITH ONE OF THE LONDON AUCTION HOUSES WORKING ON PROVENANCE BEFORE TAKING HER CURRENT POSITION WITH THE LIBRARY. THERE REALLY IS NOTHING SUSPICIOUS IN HER BACKGROUND AND I WAS INCLINED TO WRITE HER OFF AS A LEAD, BUT WHEN I GOT YOUR MESSAGE I DECIDED I WANTED TO MEET HER. I TRIED TO SET THAT UP ONLY TO BE TOLD THAT SHE IS OUT OF COUNTRY FOR A WHILE. IN CAIRO.\n", "I WILL SEE YOU THERE.\n", "HARRY\n", "\n" ] } ], "source": [ "print(caesar_decipher(c1a, key_a))" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "1113" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "open('1a.plaintext', 'w').write(caesar_decipher(c1a, key_a))" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(9, -2106.574575493358)" ] }, "execution_count": 6, "metadata": {}, "output_type": "execute_result" } ], "source": [ "key_b, score = caesar_break(c1b)\n", "key_b, score" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "the shame of my esteemed and noble kinsmen gnaeus julius agricola is a story too often told in the\n", "taverns of rome for the entertainment of fools and cowards who never once left the safety of that\n", "great city the loss of the ixth legions standard in battle haunted him throughout his life and only\n", "his untimely death brought him relief and yet the full depth of his suffering is known only to a few\n", "and even i was not taken into his confidence until after his death the truth of the peril in which\n", "he placed the entire roman army was finally revealed to me in the paper she left to me in his will\n", "among them i found this despatch from sextus varus legatus of the ixth legion to gaius suetonius\n", "paul linus proconsul and governor of britannia describing the defeat of then in that camu lo donum\n", "at the writing of this message the iceni have successfully sacked the city including the temple of\n", "claudius where the procurators guard took their heroic final stand we were almost encircled by the\n", "enemy force who seemed possessed of the power to know our thoughts where we were strong they posted\n", "only holding forces where we were weak they attacked in strength and when reinforcements attempted\n", "to join us they were attacked on route we survivors owe our lives and our thanks to gnaeus julius\n", "agricola who in a time of great emergency recognised the strategy of the insurgent forces on our\n", "left flank and commanded our retreat with moments to spare due to this action the majority of our\n", "cavalry were saved along with the reserve forces all other frontline troops have been slaughtered\n", "and it is with great sadness and deepest anger i have to report that the ixth legion lost its aquila\n", "to the enemy i fear that if we are to save londinium and ver ulan ium from a similar fate we must\n", "find the strength to crush this rebellion if we fail then all of britannia is lost this much of\n", "agricola s story is widely known but the full truth must remain hidden for now and as remarked by my\n", "trusted slave and confidant tiro what better place to hide a book than among books\n" ] } ], "source": [ "print(prettify(sanitise(caesar_decipher(c1b, key_b))))" ] }, { "cell_type": "code", "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "2058" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "open('1b.plaintext', 'w').write(prettify(sanitise(caesar_decipher(c1b, key_b))))" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.6.3" } }, "nbformat": 4, "nbformat_minor": 2 }