{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import os,sys,inspect\n", "currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))\n", "parentdir = os.path.dirname(currentdir)\n", "sys.path.insert(0,parentdir) \n", "\n", "import matplotlib.pyplot as plt\n", "%matplotlib inline\n", "\n", "from cipher.caesar import *\n", "from support.utilities import *\n", "from support.text_prettify import *\n", "\n", "c2a = open('2a.ciphertext').read()\n", "c2b = open('2b.ciphertext').read()" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(15, -1150.5844346071483)" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "key_a, score = caesar_break(c2a)\n", "key_a, score" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CHARLIE, NO NEED TO APOLOGISE, LIFE WAS GETTING DULL BEHIND A DESK AND I WAS GLAD TO HAVE AN EXCUSE TO FLY BACK TO EUROPE. I AM INTRIGUED ABOUT THE REICHSDOKTOR - I HADN'T COME ACROSS THIS BEFORE, WHEN DID YOU FIRST COME HEAR OF IT? \n", "I THINK I MAY ALREADY BE MAKING SOME PROGRESS. ON ARRIVAL I FOUND A POSTCARD WAITING FOR ME ON THE MAT AT THE EMBASSY WITH NO MESSAGE ON IT . AT LEAST THAT'S WHAT IT LOOKED LIKE AT FIRST. I DID NOTICE THAT THE LETTERS ON THE FRONT COULD BE HIGHLIGHTED TO PICK OUT THE PHRASE THE REICHSDOKTOR SO UNLESS THAT IS AN EXTRAORDINARY COINCIDENCE I FIGURED IT MUST BE RELATED TO OUR INVESTIGATION. THE STRANGEST THING WAS THAT THE POSTCARD HAD A STAMP BUT NO POSTMARK ON IT, SO IT CAN'T HAVE BEEN POSTED. SINCE IT WASN'T SIGNED I ASSUME THEY WANTED TO STAY ANONYMOUS AND I COULDN'T SEE WHY THEY WOULD HAVE TAKEN THE RISK OF HAND DELIVERING IT, BUT IN THE END I WORKED IT OUT. THERE WAS A HIDDEN MESSAGE. I'LL LEAVE IT TO YOU TO FIGURE OUT WHERE IT WAS HIDDEN. ANYWAY I'VE ATTACHED THE MESSAGE I FOUND. I KNOW THAT RELATIONS WITH THREE OF THE FOUR POWERS ARE RELATIVELY STABLE, BUT I THINK WE NEED TO KEEP THIS TO OURSELVES FOR NOW. ALL THE BEST, \n", "HARRY\n", "\n" ] } ], "source": [ "print(caesar_decipher(c2a, key_a))" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "(21, -574.2402792119872)" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "key_b, score = caesar_break(c2b)\n", "key_b, score" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "if you really want to get in the middle of this you will have to pay i know you will be hunting me and i can forgive the arrogance but i will not forgive your ignorance before you can learn more about the rat lines from me you will have to ask your colleagues in french and british intelligence what they already know powerful forces are working to keep the rat lines running and we both need to know who our enemies are before we can meet you should understand that without me your investigations will gain little negotiations with me may gain everything\n" ] } ], "source": [ "print(' '.join(segment(sanitise(caesar_decipher(c2b, 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": 1 }