From 1c711fcaa683414ec34bea0ea29269483f498343 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Wed, 18 Dec 2019 14:26:42 +0000 Subject: [PATCH] Done challenge 8 --- 2019/2019-challenge8.ipynb | 238 +++++++++++ 2019/2019-challenge8b.ipynb | 760 ++++++++++++++++++++++++++++++++++++ 2019/8a.ciphertext | 1 + 2019/8a.given.plaintext | 1 + 2019/8a.plaintext | 45 +++ 2019/8b.ciphertext | 1 + 2019/8b.given.plaintext | 1 + 2019/8b.plaintext | 25 ++ cipher/vigenere.py | 10 + 9 files changed, 1082 insertions(+) create mode 100644 2019/2019-challenge8.ipynb create mode 100644 2019/2019-challenge8b.ipynb create mode 100644 2019/8a.ciphertext create mode 100644 2019/8a.given.plaintext create mode 100644 2019/8a.plaintext create mode 100644 2019/8b.ciphertext create mode 100644 2019/8b.given.plaintext create mode 100644 2019/8b.plaintext diff --git a/2019/2019-challenge8.ipynb b/2019/2019-challenge8.ipynb new file mode 100644 index 0000000..3230e16 --- /dev/null +++ b/2019/2019-challenge8.ipynb @@ -0,0 +1,238 @@ +{ + "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) " + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "from cipher.caesar import *\n", + "from cipher.affine import *\n", + "from cipher.keyword_cipher import *\n", + "from cipher.column_transposition import *\n", + "from cipher.vigenere import *\n", + "from support.text_prettify import *\n", + "from support.utilities import *\n", + "from support.plot_frequency_histogram import *\n", + "import re" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "challenge_number = 8\n", + "plaintext_a_filename = f'{challenge_number}a.plaintext'\n", + "plaintext_b_filename = f'{challenge_number}b.plaintext'\n", + "ciphertext_a_filename = f'{challenge_number}a.ciphertext'\n", + "ciphertext_b_filename = f'{challenge_number}b.ciphertext'" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "ca = open(ciphertext_a_filename).read()\n", + "cb = open(ciphertext_b_filename).read()\n", + "\n", + "rwa = wcat(cat(reversed(w)) for w in ca.split())\n", + "ra = cat(reversed(ca))\n", + "sca = sanitise(ca)\n", + "rsca = cat(reversed(sca))\n", + "pca = letters(ca)\n", + "pta = depunctuate(ca)\n", + "\n", + "scb = sanitise(cb)\n", + "pcb = letters(cb)\n", + "rscb = cat(reversed(scb))" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.6/dist-packages/matplotlib/figure.py:445: UserWarning: Matplotlib is currently using module://ipykernel.pylab.backend_inline, which is a non-GUI backend, so cannot show the figure.\n", + " % get_backend())\n" + ] + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAbAAAAEmCAYAAAADccV0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAFWNJREFUeJzt3X+wZGV95/H3JwyoYCLCXAky6GDEZNGsCw4sLnELQRNUzLC1xIVoAJfUrFmMJsYYiJvFskIVRmtdtzYxmQgLbliEEBU2apQdUPwFOAwgM4AyKyAzBcxFlAhU+PndP/qw1cwP+tzuvsw8c9+vqlvT5+nn6fPtvt396efpc8+kqpAkqTU/s70LkCRpHAaYJKlJBpgkqUkGmCSpSQaYJKlJBpgkqUkGmCSpSQaYJKlJBpgkqUkGmCSpSYu2dwEAixcvrqVLl27vMiRJO4DrrrvuvqqaGdVvhwiwpUuXsnr16u1dhiRpB5Dkzj79XEKUJDXJA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/FI8hoGz+N3dDP8vsZ9TL7ejds9yR4MnmN9Vi0+BxzDYKn0y3Oo86+APwEuAD4yh3FNWygzsN5/rV1VP+oOHFgLfKmq/rDn0F8GPprkSeAx4HfGqHNeVdW67kW4saru7jns68AHgW9X1UNJ/ol+L0QY/A8DpyU5l8Hs5pNzLrqHqro5yX8CvpLB0VCPAacBd/Yc/1CSY4HLkzxYVX2WieZ63/4BeFeSW7qxvZZeulnwhxl8/7gRuLXnuHVJzgK+luQJBt/xnTJizJokFwE3ApsYnNN0h1JV30lyGYPVgHsZLC/3Wa5/N7AXcGUSGJyI9rd77G+sx6Qbdx6D3xvAp7pl/FHjHu0OMPlJVT3RZ19JTgIeq6r/1R289K0kR1XVFX3Gt2ynPxNH9wl0TVX1/UQuPaMkS4G/r6q+R3o1qTva8cGq+tj2rmVYkudX1YPdkZ9XASuqas32rmsaug9ga4DfqKrbtnc9O7qdegmxW9b7NoOjcyTtHFZ2B+usAf5uJwqvgxgc5bjK8Opnp5+BSZJ2Tjv1DEyStPMywCRJTTLAJElNMsAkSU0ywCRJTTLAJElN+n8yzCjn0bwVXwAAAABJRU5ErkJggg==\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "fc = collections.Counter(sca)\n", + "plot_frequency_histogram(fc, sort_key=fc.get)" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "abcdefghijklmnopqrstuvwxyz \n", + "\n" + ] + }, + { + "data": { + "text/plain": [ + "'harryiputtogetherateamofwomenfromthecomputingdivisionhereatkennedyandwehavespentmostofthelasteighteenmonthscombingthroughmissionfilesandcomputerprintoutslookingformorecluestothesourceoftheoxygentankexplosiononboardapolloxiiiandithinkwehavefinallyworkedoutwhathappenedthetankcontainingthesourceoftheexplosionwasoriginallyinstalledinapolloxbutremovedformodificationduringthatprocessitgotdroppedsoitwasheldbackforfurthertestsandareplacementfittedforthatflightonceithadpassedinspectionthetankwasreturnedtoserviceandearmarkedforodysseyfurtherupgradeswerecarriedouttoallowittorunoffgroundpowerduringfitoutattwicethespaceshipvoltageandthehigherpowerwasusedtoboiloffexcessoxygenduringgroundtestsunfortunatelyitlookslikethethermostaticswitchesinthetankwereoverlookedduringthevoltageupgradeandourbestguessisthattheyfusedclosedduringtheboiloffallowingthetemperaturetorisetooverathousanddegreesyoumightthinkthetestengineerswouldhavenoticedthatbutsincethetankoperatingtemperaturewassupposedtobesomewherewellbelowzerothedialonlywentasfaraspluseightysonoonewouldhavenoticedoperatingthatfaroutofnormalrangeitisamiraclethetanklastedaslongasitdidandthataddstotheimpressionthatthiswasasimpleaccidentachainofeventsthatcouldnothavebeenforeseenbutthecomputerfilestelladifferentstorywefoundtwoversionsoftheupgradereportwhichwaswrittentodetailtheproceduresformodifyingtheelectricalsystemonthetankthefirstgivesacomprehensivelistofthecablingswitchgearandcontrolsystemsthatneededtobehardenedforthegroundbasedvoltageitlistseverycriticalcomponentexceptthethermostaticvalvesthisdocumentwasfiledintheservicerecordsoweknowitwastheofficialrecordbutthechiefsystemsengineerwhosigneditoffsaysthesignatureonitisabadcopyofhisownwefoundidenticalcopiesinseveralmissionfilesbothinthemanufacturersrecordsandatkennedywheresomeofthetestswerecarriedoutsoitisclearthatthiswastheofficialversionusedintheupgradethesecondversionappearedtobethesamedocumentbutitincludedthethermostaticvalvesonthelistofcomponentstobechangedandthetemperaturegaugelimitswerecircledseveraltimeswithanexclamationmarknexttotheeightydegreeceilingitlookslikeoursaboteurdeliberatelyarrangedforthetanktobemisconfiguredinanefforttocausetroubleforthemissionalthoughwecantbesuretheyrealisedhowdangerousthiswaswhenweputittogetherwithalltheotheraccidentsitisprettyclearthiswasanotherdeliberateattackontheprogramwefoundthesecondversionofthereportinaboxunderthefloorboardsinmikesplaceisupposeitispossiblethatmikehadstumbledacrossthedocumenthimselfandwasinvestigatingitaspartofhiscampaigntoprovethattherussianswerebehindthisstringofproblemsbutattheveryleastheisguiltyofamajormisjudgementandiftheastronautshaddiedhewouldhavebeentriedformanslaughterasitistogetherwiththeleakchargeshewillbegoingtoprisonforaverylongtimeofcoursetheevidenceisstilllargelycircumstantialwecandefinitelytiehimtotheleaktothenewspaperforensicsmatchedthetypewriterribbonandtypecharacteristicsonhistypewriterwiththeinkandimpressionsonthelettertotheeditorbutwestillcannotshowconclusivelythathedirectedorcarriedoutanyofthesabotageattemptsandwehavenotbeenabletofindanyoneelsewhohadbothmotiveandopportunitysoheisourbestsuspectiamnotsurewecanentirelyrelaxbutwithnosignificantincidentsonapolloxivtoxviandwithmikeincustodyifeelslightlylessworriedabouttheremainingapolloflightwearestilltryingtocrackthatotherenciphereddocumentwefoundinmikesplaceithasaverystrangealphabetwhichithinkmustbesignificantbuticantquiteseehowtobreakityetnowthatthenasacomputingexpertshavemoretimeiamhopingthatweshouldbeabletodecipheritandthatitwillshedsomemorelightonmikesthinkingmoreimportantlyitmighttelluswhatelseifanythinghehadplannedmeg'" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "k_a, score_b = vigenere_frequency_break(sca, fitness=Ptrigrams, max_key_length=26)\n", + "print(k_a, '\\n')\n", + "pa = vigenere_decipher(sca, k_a)\n", + "pa" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "harry i put together a team of women from the computing division here at kennedy and we have spent\n", + "most of the last eighteen months combing through mission files and computer printouts looking for\n", + "more clues to the source of the oxygen tank explosion onboard apollo xiii and i think we have\n", + "finally worked out what happened the tank containing the source of the explosion was originally\n", + "installed in apollo x but removed for modification during that process it got dropped so it was held\n", + "back for further tests and a replacement fitted for that flight once it had passed inspection the\n", + "tank was returned to service and earmarked for odyssey further upgrades were carried out to allow it\n", + "to runoff ground power during fit out at twice the spaceship voltage and the higher power was used\n", + "to boil off excess oxygen during ground tests unfortunately it looks like the thermostatic switches\n", + "in the tank were overlooked during the voltage upgrade and our best guess is that they fused closed\n", + "during the boil off allowing the temperature to rise to over a thousand degrees you might think the\n", + "test engineers would have noticed that but since the tank operating temperature was supposed to be\n", + "somewhere well below zero the dial only went as far as plus eighty sono one would have noticed\n", + "operating that far out of normal range it is a miracle the tank lasted as long as it did and that\n", + "adds to the impression that this was a simple accident a chain of events that could not have been\n", + "foreseen but the computer file stella different story we found two versions of the upgrade report\n", + "which was written to detail the procedures for modifying the electrical system on the tank the first\n", + "gives a comprehensive list of the cabling switchgear and control systems that needed to be hardened\n", + "for the ground based voltage it lists every critical component except the thermostatic valves this\n", + "document was filed in the service records owe know it was the official record but the chief systems\n", + "engineer who signed it off says the signature on it is a badcopy of his own we found identical\n", + "copies in several mission files both in the manufacturers records and at kennedy where some of the\n", + "tests were carried out so it is clear that this was the official version used in the upgrade the\n", + "second version appeared to be the same document but it included the thermostatic valves on the list\n", + "of components to be changed and the temperature gauge limits were circled several times with an\n", + "exclamation mark next to the eighty degree ceiling it looks like our saboteur deliberately arranged\n", + "for the tank to be misconfigured in an effort to cause trouble for the mission although we cant be\n", + "sure they realised how dangerous this was when we put it together with all the other accidents it is\n", + "pretty clear this was another deliberate attack on the program we found the second version of the\n", + "report in a box under the floorboards in mikes place i suppose it is possible that mike had stumbled\n", + "across the document himself and was investigating it as part of his campaign to prove that the\n", + "russians were behind this string of problems but at the very least he is guilty of a major\n", + "misjudgement and if the astronauts had died he would have been tried for manslaughter as it is\n", + "together with the leak charges he will be going to prison for a very longtime of course the evidence\n", + "is still largely circumstantial we can definitely tie him to the leak to the newspaper forensics\n", + "matched the typewriter ribbon and type characteristics on his typewriter with the ink and\n", + "impressions on the letter to the editor but we still can not show conclusively that he directed or\n", + "carried out any of the sabotage attempts and we have not be enable to find anyone else who had both\n", + "motive and opportunity so he is our best suspect i am not sure we can entirely relax but with no\n", + "significant incidents on apollo xiv to xvi and with mike in custody i feel slightly less worried\n", + "about the remaining apollo flight we are still trying to crack that other enciphered document we\n", + "found in mikes place it has a very strange alphabet which i think must be significant but icant\n", + "quite see how to break it yet now that the nasa computing experts have more time i am hoping that we\n", + "should be able to decipher it and that it will shed some more light on mikes thinking more\n", + "importantly it might tell us what elseif anything he had planned meg\n" + ] + } + ], + "source": [ + "print(lcat(tpack(segment(pa))))" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "4375" + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "open(plaintext_a_filename, 'w').write(lcat(tpack(segment(pa))))" + ] + }, + { + "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.9" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/2019/2019-challenge8b.ipynb b/2019/2019-challenge8b.ipynb new file mode 100644 index 0000000..50c4421 --- /dev/null +++ b/2019/2019-challenge8b.ipynb @@ -0,0 +1,760 @@ +{ + "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) " + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "from cipher.caesar import *\n", + "from cipher.affine import *\n", + "from cipher.keyword_cipher import *\n", + "from cipher.column_transposition import *\n", + "from cipher.vigenere import *\n", + "from support.text_prettify import *\n", + "from support.utilities import *\n", + "from support.plot_frequency_histogram import *\n", + "import re" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "challenge_number = 8\n", + "plaintext_a_filename = f'{challenge_number}a.plaintext'\n", + "plaintext_b_filename = f'{challenge_number}b.plaintext'\n", + "ciphertext_a_filename = f'{challenge_number}a.ciphertext'\n", + "ciphertext_b_filename = f'{challenge_number}b.ciphertext'" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "ca = open(ciphertext_a_filename).read()\n", + "cb = open(ciphertext_b_filename).read()\n", + "\n", + "rwa = wcat(cat(reversed(w)) for w in ca.split())\n", + "ra = cat(reversed(ca))\n", + "sca = sanitise(ca)\n", + "rsca = cat(reversed(sca))\n", + "pca = letters(ca)\n", + "pta = depunctuate(ca)\n", + "\n", + "scb = sanitise(cb)\n", + "pcb = letters(cb)\n", + "rscb = cat(reversed(scb))" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "name": "stderr", + "output_type": "stream", + "text": [ + "/usr/local/lib/python3.6/dist-packages/matplotlib/figure.py:445: UserWarning: Matplotlib is currently using module://ipykernel.pylab.backend_inline, which is a non-GUI backend, so cannot show the figure.\n", + " % get_backend())\n" + ] + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAbAAAAEmCAYAAAADccV0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAEi9JREFUeJzt3W2wXVV9x/Hvr8SnqmN4uGaYJBodMyq+AOGWQrEdJdoRUEOniE+VSNO5dYpVazttbO3YF+0MvimVGUubim2wVkUsTarUygQtox0sF3lQQEukpEkK5KqAIqNW+++LszJeYsg9Nzk35y7u9zNz5qy99tpn/08S+N21zj77pqqQJKk3PzPuAiRJOhQGmCSpSwaYJKlLBpgkqUsGmCSpSwaYJKlLBpgkqUsGmCSpSwaY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/gd4WVVdMs5ahmGAwa6q+mJr/z3wkjHW8ovA1VX1SFV9h/F/AfwMYGtVfb+qvgv885jrAZgAtgJvqqpbx10M8F9VdUtr3wSsGWMti82ZwCeq6psAVfXtMdcDg9C6FbiBwR2D1o6xlnXAKcCNSW5p288dYz3d8TMw2P97BH6vYHF7CPhvBj9o3DHmWgB+MKv9Y2DsS4g6sCQvBV4OnF5VjyT5PPDkcZYEbKmqd4+xhq45A4NnJTm9td8IfGGMtVwPnJvkKUmeDrx6jLUAfBF4dZInJ3ka8Kox1wPwQ+BXgAuSvHHcxeigrgNeu2+ZLskxY67nGcADLbxeAJw25nq2A+cleSYM/nySPHvMNXXFGdjgLvgXJfkQg5/oLxtXIVX15SQfB24F9jK4r+TYVNWNSbYBtwH3A19hMAMaq6r6XpJXAdcmebiqxr3UqgOoqtuT/Bnwb0l+DNwMvGWMJX0GeGuSOxn8d3/DGGuhqu5I8h7gs0l+Bvhf4CJg5zjr6ol34tBBJXlaVT3crs68Hpiqqi+Puy5JcgamuWxOcgKDzwq2GF6SFgtnYJKkLnkRhySpSwaYJKlLBpgkqUsGmCSpSwaYJKlLBpgkqUv/D/eKgjHokfDqAAAAAElFTkSuQmCC\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "fc = collections.Counter(scb)\n", + "plot_frequency_histogram(fc, sort_key=fc.get)" + ] + }, + { + "cell_type": "code", + "execution_count": 17, + "metadata": {}, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAbAAAAEmCAYAAAADccV0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAFQlJREFUeJzt3X+0ZWV93/H3R7CgggLOzRRHzCV2TBbJiphM0EbLwiU1Ik0HktS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cvwHcneRfdP2S5Llj9PsmS28bwzzIZNtHv6+OUetiNne1P53eLy43LdF2cLluB16f5PBuzFHbyNOAe7vHrx2jtn7b6TsnmGTY9rHYmA904fVi4HvH7HcN8MZ0u7PdUa5VcSgGGFX19/Q2ljfRO7Z8I3AZvWPol1XVUocPqapPAn8M3JDkdnqHcY6esIxzgV/uDh99FviHfe9/E717Q+6kd8L4dnq/wb0O+P0kt7LEhQp979M/n3uA89I7wf0DwN8PtB02JvQO73wB+ABw/hjjfqJ7rx1drWNdbjxgkjHfCZyaZBe9Q4l/NaSuYfP4NnrnXT4D/MWEdY7Vd+Cz+D/AUUnuAv49vcNY47gJeB+9QzF3A5eP0edyeueW7gQ+AtwwqsNArfd1fW9J71LwP2DgyMwSy/XVwPndOreL3v/8G6ff0G1jhIm2jwFL1jrETuA64HPAu6rqK0s1HliuX6G3nu7sxnzVUn2B/wj8ZrdNTHpk7N3AseldMHIbo3+JWfBRYFP3M+41jL9tvIveIc6d3Tb5rgnrnRrvxLFKkhxVVV/vfvu8HthSVbccamMeaGthHlfDcpern4dm6VA8B9aKC5OcRO+Y88UHaKNejTEPtLUwj6thucvVz0Mz4x6YJKlJh+Q5MEnSoc8AkyQ1yQCTJDXJAJMkNckAkyQ1yQCTJDXp/wMuzXS3xlEXKwAAAABJRU5ErkJggg==\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "fc = collections.Counter(chunks(scb, 2))\n", + "plot_frequency_histogram(fc, sort_key=fc.get)" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "{'fe': 'e',\n", + " 'ia': 't',\n", + " 'fc': 'o',\n", + " 'fb': 'a',\n", + " 'kc': 'i',\n", + " 'fa': 'n',\n", + " 'he': 'h',\n", + " 'gc': 's',\n", + " 'hd': 'r',\n", + " 'ge': 'd',\n", + " 'ke': 'l',\n", + " 'ib': 'u',\n", + " 'id': 'm',\n", + " 'kd': 'w',\n", + " 'ha': 'y',\n", + " 'ga': 'c',\n", + " 'fd': 'f',\n", + " 'hb': 'g',\n", + " 'gb': 'p',\n", + " 'ic': 'b',\n", + " 'ka': 'v',\n", + " 'gd': 'k',\n", + " 'ie': 'x',\n", + " 'hc': 'j',\n", + " 'kb': 'q'}" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "p_common = [p[0] for p in collections.Counter(chunks(scb, 2)).most_common()]\n", + "e_common = [p[0] for p in english_counts.most_common()]\n", + "bsubs = {p: c for p, c in zip(p_common, e_common)}\n", + "bsubs" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'actseleitsocourhonankoreitiupstyeinvtsanpatahtsitoureccorthtowontiantsehobaethfvgroxvmirhahlooyelihyvdoitsanpoctsehobaeteygaremihhtokelfvsahleitstseuhhrceelhontseinpertsitmehtarugmatseiwsmirmecapstanathguggethtitehmesibetraeltowontianatfutanomreidahetsitmewinondvleceitattsemivmecoupstcihwahyfvtikanponathyapstanogenmirourgodatawainhsibehsrunkcroytsewoncdawtinltsevneelireihontowoncronttseebadebentsetsreitocnuwdeiryahhadehfihelanwufilalnotpabetseytseyettdetocapstanhteiltsevsibewonbanweltseyhedbehtsittseyillowtraneocyutuiddvihhurellehtruwtaonmaddgrotewtuhinltsitgeiwewinfeyiantianelunlertsehsedteroctsenuwdeiruyfredditsevlonotheeytoheetsittsedonpermewomerantsahhsilomtseyoretsetmohalehmaddanbehtantseheimcudmeigonhfecoredonpatmaddfeaygohhafdetocapstitiddmatsouttsetsreitoctotidinnasaditaoninlmsentsitlivwoyehmemaddiddfeenhdibelfvmsoeberahyorerutsdehhdoheinlmemaddfetsehdibehtsegraweocmannanpyapstfemorheitcarhtasogeltsittsehgiweriwemoudlsedguhturnanptseyahhadehcroymeigonhocmirtowirraerhocgeiweinlkennelvheeyeltosibetsitanyanlmsensehetsahgropriytodinlontseyoonfvmannanptsehgiweriwetseilyanahtritaonsogeltoehtifdahstsehugreyiwvoctsewigatidahthvhteyoberwoyyunahywomanpoureneyaehinlhettanpourseirthinlyanlhontsewonjuehtocinemcrontaerfutfreqsnebheeyhunleterrelinlebenfecoretsediunwsocigoddoxatseiyerawingufdawahfepannanptopetforeltsetsreitocnuwdeirmirahrahanpinltsegeiwegrotehthmsawsireantenleltogrebentatireenwouripanpoureneyaehtofedaebetsittsevwinmanmirahuniboalifdetohurbabeatmeyuhtcapstatnomonouromnteryhfecoretsenuwdeirirhenidhpromtoogomercudacourdeilerhmaddnotiwtoctsearomnbodataontsenamaddgroboketserejuarelwoncrontitaonamaddwonbanwetseytsittseruhhainhsibehifotipeltsedunirgropriyinlkaddeloritteygteltokaddourihtroniuthtseruhhainhmaddneberfeifdetogrobetsittsevireannowentinlourgodatawainhinlpeneridhmaddfecorweltohtrakefiwktseruhhainhmaddehwiditeanorlertonotdookmeikinlonwetsevsibewoyyatteltseyhedbehtseremaddfenoturnanpfiwktseuniboalifdemirmaddsibetofecoupsttoathwonwduhaon'" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "comcb = cat(bsubs[p] for p in chunks(scb, 2))\n", + "comcb" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "('ifwlecpsazkdynogjrhtubmxvq', -6624.359993210847)" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "kb, scoreb = simulated_annealing_break(comcb, fitness=Ptrigrams)\n", + "kb, scoreb" + ] + }, + { + "cell_type": "code", + "execution_count": 32, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'ifthedeathofoursoninkoreataughtmeanythingitisthatoureffortstocontainthesovietsbyproxywarsisdoomedasmyloathingofthesovietempirewasstokedbyhisdeaththeussrfeedsontheangerthatwestirupwitheachwarwefightinitspuppetstateswehavetriedtocontainitbutinowrealisethatwecanonlydefeatitthewaywefoughtfascismbytakingonitsmightinopenwarourpoliticianshaveshrunkfromtheconflictandtheyneedareasontoconfronttheevileventhethreatofnuclearmissilesbasedincubadidnotgivethemthemettletofightinsteadtheyhaveconvincedthemselvesthatthemaddoctrineofmutuallyassureddestructionwillprotectusandthatpeacecanbemaintainedundertheshelterofthenuclearumbrellatheydonotseemtoseethatthelongerwecowerinthisshadowthemorethetwosideswillinvestintheseawfulweaponsbeforelongitwillbeimpossibletofightatallwithoutthethreatoftotalannihilationandwhenthatdaycomeswewillallbeenslavedbywhoeverismoreruthlessloseandwewillbetheslavesthepriceofwinningmightbeworseatfirstihopedthatthespaceracewouldhelpusturningthemissilesfromweaponsofwartocarriersofpeaceandkennedyseemedtohavethatinmindwhenhesethisprogramtolandonthemoonbywinningthespaceracetheadministrationhopedtoestablishthesupremacyofthecapitalistsystemovercommunismcowingourenemiesandsettingourheartsandmindsontheconquestofanewfrontierbutbrezhnevseemsundeterredandevenbeforethelaunchofapolloxitheamericanpublicisbeginningtogetboredthethreatofnuclearwarisrisingandthepeaceprotestswhichareintendedtopreventitareencouragingourenemiestobelievethattheycanwinwarisunavoidabletosurviveitwemustfightitnowonourowntermsbeforethenucleararsenalsgrowtoopowerfulifourleaderswillnotactoftheirownvolitiontheniwillprovoketherequiredconfrontationiwillconvincethemthattherussianshavesabotagedthelunarprogramandkilledorattemptedtokillourastronautstherussianswillneverbeabletoprovethattheyareinnocentandourpoliticiansandgeneralswillbeforcedtostrikebacktherussianswillescalateinordertonotlookweakandoncetheyhavecommittedthemselvestherewillbenoturningbacktheunavoidablewarwillhavetobefoughttoitsconclusion'" + ] + }, + "execution_count": 32, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pb = keyword_decipher(comcb, kb, KeywordWrapAlphabet.from_last)\n", + "pb" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print(lcat(tpack(segment(pb))))" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "([5, 1, 6, 0, 8, 0, 6, 2, 5, 4, 9, 4], 'fbgaiagcfeke')" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "db = [9 if c == 'k' else pos(c) for c in scb]\n", + "db[:12], scb[:12]" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "([6, 2, 7, 1, 9, 1, 7, 3, 6, 5, 11, 5], 'fbgaiagcfeke')" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "db = [pos(c) + 1 for c in scb]\n", + "db[:12], scb[:12]" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "3958" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(scb)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1980" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "gpb = open('8b.given.plaintext').read()\n", + "len(gpb)" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "1.998989898989899" + ] + }, + "execution_count": 14, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "len(scb) / len(gpb)" + ] + }, + { + "cell_type": "code", + "execution_count": 34, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "uobonssahasosonncsm \n", + "\n" + ] + }, + { + "data": { + "text/plain": [ + "'gnjfkrwbuvtjrozolhaquxrcbuswhcbadmblzkgceakhrtrpgjraehcmmloqrrclqgbyemeuamqhlsptcgldmgjnxrbywtolholuiemttyteeaaobdfsnbhhnayydlhgnpanykrropibfywemsuhlwcgitiwpwtuhgcocwouxkqkipztlaqeauriqhtaekssfjgokbcthevolgnhdcewhzxywvmihnljtaielykslrbxrtozeidxcuvmtadfhimrhrxyyxosphgeokbsmqcxvtsjntcitohioxtuakpbqotpteegrmddgmxwtncovryguairzciaacrtmnpwricwbubkdcwcknvgofbizlmomlipnisvetvokddqsctcakficaenovanoryazwajmmuqmnulhmozpkbwzjryknhkkvtyuwwkninmknlfhugubugdkyhshychglvhdcfdpfdmycnubstchfmdtgosvhcsmupamtyigddaukaenaxgnpwfwvcckjnwnzfyvtjexuignsmwyysmvunamtuzcemaxashmauzvrryjtaotqlcfaflymnwzuhcsttetcnndhligpfccxrtudmjjgfgmapyttfkezdcbnuhkqtrbiorlkplajadnfyiuyholbssjknshskdjumirmosyykaletnlmdajlxnptowuohhkuwukohkmxmfupyrzcwkacdegxmouwgciwgnoebrjwtongivyesgupsvoyrgyesehzclfnwykuzpllihllrlelmkexfomxtbfgpoccuwygjoqlddbeookwnbkummtghgsraxbiefuldqfxuzazzrystngupakskecuydeonaowjoslnfgaylvewhzavcvhwffoxzutyrjcofhasysuqwhxaohrxgtciiuysbustveprwprmestwysuwgdtuyfhrmsfdnxcucbjoiowfvpdrkshlullmghgupusjqhcornakbdpmiiiahvnknubfrmecfrkbmmuofbhsevircmfxknfpqutgefeuskhiexmuicdephibhehigcmiwsnxzbmktyobdwsgfagriziiaygwnusuneafndvgadlnehrsktmpzcokggiqtewqsgcoftgepmeelggmyokyahwidotmchhwvxzckrmjlhenfamjrqjornmqokgqcmnnebmltbebbegeplcldhxbutyinxntnhqbrsapiusehtpngwmciflianertxvaxnsumvfeglhbwigsimnagudpyiprexdnucbtgfqgragdonscuzocjenkegdjqqwaocrkdpudgsauwkihubrutaidhnaemshwnwycrhopevjwkxkoyfkfzfcnijggskuypoqfagegrnreyejumsdwergbkrdirebgkilecctgvemrwsktmfeauialfrgfgsxywobcwxhcnqyiacunwwlncdnseoohaoaozhhyxwgrlsaymlchdslpjsspgciftaudtmdfporuivocaydhmnelntaljladdtjfnnzywcczfgnwhschpvbdynyektcrhjntaffiihyfybetibtxgtrlqsgncsqshpmtyuacnapefazukgxaofzrytercbrddmanndybsjmcpmxhscsaetndmfptoclcsezwoqvbiuhxjyxdacsnzbylmqywrsugfnwykkggdufraolgqlyselntmogsodxkojundoowqmeulhbspyhgpjyviuygtawviegyfqchlfsxptfkpxsbeazochcywevrctikdktfsfmgwyynucitvaaldrhtxeklsugpanvrhcfktsclmetgcsixaoabthxhnyrpmhobnsefbfhnyugjesojdvieeiksgrctitdishseukymbnhhtnhhlubdwncvpfetesejkdiesrlyowrdolcaxabrcuitmhuxougbypyxpktebprpqopwerfhegrxhqmgagjovsoljvtbonloywswaehngsliydnowgdewbkpfympprodqvwkthanknkeoqmtbegofyxbynpomqczitohmaeitqxyrnpefnenuwimedjiiztaxlrsdttkotntkgvhcsehbkuycinjnvpfpgrrrqhowgzzyykdhacripbarvebmsmipzarmnfxmiegiulkdffeourglmatyuewogemnw'" + ] + }, + "execution_count": 34, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "k_b, score_b = vigenere_frequency_break(rscb, fitness=Ptrigrams)\n", + "print(k_b, '\\n')\n", + "pb = vigenere_decipher(rscb, k_b)\n", + "pb" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'NTNQVATAVHRAYMFTPAVRIAGFYETSWGUYGDASHLHGOAASNBJGTUTCUNVPFGZNEIZQVFBNCPXDYFEESZAQUANLQCDOAUFADOPHAGEDNVLGHTAWWLEKLTFBYTOSAMOITEVXAWMGCPXLGEHGCLPYVBGKTQGONEDGMZHHRVDIJOYGUCFWHYFCDELBLGGTQLOLWNJFQEBHOEYFZSYFKUSESUUKCIKGLQVLPGBYBAOEQOFVAYKWFWHWGRWMVUYGSZLGORKODQSLNOTUGCHNVHPGUNBQDQLCXVGAXFGBBVVPEWWCGTEELUNRJGUKWURYEPFVUGPZTFIC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ANHTZYSYAPPASSHNVCZLVNNRRRFSCQFTLGKQBNDZSFOYRURDDZVUNDDFSMAXWPFVMPHTTTCQUOOYASMHYYZUKCOPQGYJGCVKTUAWNNGSTFWJVGZAWWMRKYUWSNFGUFMVVOAJFZGKYFKSZWHAYOVMDZYBCLGWBOZVCIJHMGTEAUZSHYATXYWNQPDFGBYRHETAOYLCDDOWNFFRSWVMUGDBZSBYXGNQLCFQGOSDQMUWRIZQFGVWFWBORUDAGWFUQPFGHFEVDUGWFONGFQJLXRKWASHGNKLQKMCUFOEHHMEWYULBGUESUGVJFQAHDKFWVGAQLYOZVZQKAHCCEFSWHRQSMKHEFOPUACYXIPQDYCCVAYMKOYAVPEWHZGVHYMBBGVYQVFUAUTAZWVQUXDWFVAQQFELOUYGWPSWNVVSBGFLNBOMDANIDEFUSHECRDXOYRVLMLBUURAMFDOFVPYTGVYEQJUCNCGGTTWMYOGYFWQBVKNEAVGYVRDEAFIVJCKLMARPTEGHCGGWSLAERTEPWANUCNFLTWSULNDWNSXYTGNWWQKEMHGHBRSZAMYHJLQMKBUHTASPYOKEQJXNHKXAGWWMGGXTGCBJTZSNCYTPZPWSXVMPQWCMAVFZWGCAQFMLGYJTFWWAKIUYYUSCHJKCOLUOGUCUKBHZCCEWQNGDSQLAMFAEUGCAFVPZHAWMATQHWSNNQTPZGOPUZFAFYVZZUACCFKEFSCCATFPYXJORUEEYFCRFEUDQNBQSESHNOITFGQHPYDDTGBBPFOLYLABKTXJOBBVLXJCMBNZMKIYFPTMSDHUPSRZONRWAQFOXZJTY'" + ] + }, + "execution_count": 30, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "rlcb = cat(cat(reversed(l)) for l in cb.split())\n", + "rlcb" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "auaasnonhcncipbobsny \n", + "\n" + ] + }, + { + "data": { + "text/plain": [ + "'NZNQDNFNOFEYQXEFOI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CFZLBUSHDQLNVEYAWFOFMVGR'" + ] + }, + "execution_count": 35, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "k_b, score_b = vigenere_frequency_break(rlcb, fitness=Ptrigrams)\n", + "print(k_b, '\\n')\n", + "pb = vigenere_decipher(rlcb, k_b)\n", + "pb" + ] + }, + { + "cell_type": "code", + "execution_count": 36, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "sonyas \n", + "\n" + ] + }, + { + "data": { + "text/plain": [ + "'rnauaiwsunhaiptauoeeggynomvtvixfsoyiztictidcavnwlmswawlodnniccnbsmmrlfxxkzohvyhurpzonbipukbggicopqtnxxkszyafdqgkouiebvyjnfymeteinvhothafeoitcnotyftiljtqqefgpiseuogawkddztubmolqaqgybwtdvgxxxaadnadgoijkoiptdcyikqkwhwsmagxhyahrlgopjqdhjvehkelylcopuoxtiphkoggqntacqqkzwsybsoggiowzoiuyfedgslrkqrgbpochsregzgjmuordawlmmftewembixbjorkcgyxgfrxaszvqzmkrmdbrhhbpcatmflgtelmfgvejrwernauibaloenudtbqenqpmdonngalbtbbzjxmdocwlwenomwbvjeigpzfeujlsneuwiautfehwksgomevkdryhtpgrbfusmfkokhadjokwergiiqicyasyqsntoervvziepolrjjhosgecvbzhxfmmevyxdzppjugpdkfzlguvxnujtmlggysnyfitypmljitudzhcedyrpslytmrotowbttuzaefsopwejngiphxszknksgmnvecxodpicsfnpmnutjptibtxokjofgsnajuybhdbypubdqmzvgsdlyznmfxadmlufihpscuoqiihijfrmiruwxsrcgprtmdnmhwryiyaxnyowbyxivqyteujkithdrvpblbdyghssixhcmujdidrfcogytdkdtbytmbdfqjhaihpocokiayxedcfjkwgfuqxsauysyavaagegzgtcrsyzhtcjisemhfofopgzibnizlsilcnerbwgvagmbfdvtzhtcwupqhwbgkihnfqdiowyjwxyzgaffoojtcifkdsutyqaghrwonrxtfpeccmugamnlgicaqwycefaobanbalyptcsevgbmdgwvvtywsbqoouumwqmdlvmznsgqkxordmgofasbjxondhxrojycafkeiindiliremovhyhzjbfkydkewhhbnwcfcawplgoyrinteimffcvdtgtnmafnqxokpdqilsseumcesbvivhihswnnbgmxrfzuwihbeasacfxznoiskctvxzmyamxgwxybbwhesdymhvxeiglvigzivihmpfsmenmgrywaufgjbpiqcerukirgtkqtjhxcvinyexsnpuanxcoebcpovavgueyodcoxszbvpvoygfbooepnyfgclbfmuirgsyfhwtsdnudylttkgoubxabqigtwynjmfburmytssppjtrxauzttzjafbxnkkmebjaelfoypiktixwwtaiwyuhdawsuzpkyjtestrzvzinzkdzuusixbnasghfupawefclxkoegfktqsjwzswahscbbfurmdnbjzauarqfncdlqfrczkbhshlzoskotfsscvaihakzuijczodvjhtaozayacbwiegrgsdroksgmaypuenaambszjjqkhmqbeoxpdyhlyiqyipimukngwtbfriaixmncssabahnqiuudiftfnvibfdktkbctmpdldgnlbdpwgffnahahgtwddmruifxygsygilgeqbeniiifyhueyuuypfqgynoysnofcslvocerwgjtglyeuptrqfckyxslsvsuuaesdknjynsaqfegpdrifgonwpwnqummayduysnmopjasylibogtcnivenwqjayymihwlfgdxwhifhcundclxgjjyljvohtjgpdikbmmgihpeujtyyxrgwjqtcmpehhelqznfmwjzyhgjahipwaxitauwtqsfrdgsicevshoswngsbamebfticvkgwsegdsgapdnaqhmizgfpwlvxhuwbtraeuviicgtzmmyuwooouiebxdnolskvikfimsnzkpvjwseswkcuabpgommytvuamiheedhopyrmqeeztvyfbvliluncnegehricmkeccovfaicbpbgoauzbrnpitfoszywkogrcfuixdudovcjgckhtomukcsbwlwkwwjcacklwisiijhfbiopufmsrpeachliafinlhroohbgsnvaiustiuinjzxdrnnytwrcdbobpqappyssviwvtfgsyjzdfumndphymmgeqjfgblvjhfassaezzbbraxgufsubbsaisuladmkrjyxbjwvkvkji'" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "k_b, score_b = vigenere_keyword_break(scb, fitness=Ptrigrams)\n", + "print(k_b, '\\n')\n", + "pb = vigenere_decipher(scb, k_b)\n", + "pb" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "zns \n", + "\n" + ] + }, + { + "data": { + "text/plain": [ + "'bosukrpojwyfkpucahnxqzsxuzaeucqfzabvsjirswymrulxzkrpecfrggpzgrcedvcdaffpobqusoruxzqlutjccnpygmnnwchinennbruetavrgxatwqhhgnnzihahidpnlrntpkbgngjebxqvlgvfkiwsdbtvbovpclopapkfjyotltdtbznbrchpexzohkbhpjkghtakzgxacetkdncyxpubinajodnygzthlrukgutvxjylruitpceaanuzurmdulocigitcgpxmrwfousynofnnjirdxtnnzqgmhukhtetyifebfcebacdanmgethtoqeofcsnugqwgixzgowlmrwcdakhtbujuzbozserodlambiozizesmmbczteqfeoidtoogyvcbuenvjqmghairksqfplzwyumocdpdblulbgbixfjpatdilucoowlywscbhbbmewdcyqegiirdiiqsgjdhnymlwaihrxiipkfsaxuzrfulumgbxvnkzkqqdlzjnpaogdrmkzljituooxtrxudhnprpizmxlcmoovravtdksyytvrykgdopflrzcxeqadnhiegjjpecenoxscrcnhunfilvtcafpznbyleodxesoclzirbbbgmplebeosnsfewzchqjafjzsovsuwiwbwnatszsstmeingpiuemgcpthjjpmddvrizouriznanugzmclpwqdozwodisuhixavhfbgjrwthbjeneszhetakrsbmtsrovemagbgshzeqhwhveqntziyjxgiuqubugkrhwpxhvjojysegahpfkcbxbioubalaznxqnatuvwphmivoezssamogjpvnxezddndehappbfhtgbugnfhxfraeidpvwbbtohstvnffqtfiuartufwcaficsgvtcbvjzxxntojtpedltnzlyegfullzhuiygtbgbrsxdokukoxoriajysthhlnyanldzvkihjdoyqsitpjlcmxneohfgjpjpbfredzzdcmbujigbnfexrcfsmlsbirphveslqulcbjfuhiriadhsuggwwcqrixmvqabbkobtvyxbvfazexanetzbkcufbjgbagidondasavrcdsoenycpghcymfwfsbftzohnemexyvhruhltowwvkkvnxamedkzrpnajvadpuoixwqkizgnqdkbthgionqmlmotcgazfkzrlqotdvornvfatcmmprctokjgavypoaefdiulddsymugkaxgfjnabxhgvqwvnoknitlclcyxunsxngteqhctvgsuowpnhcpctwefwzegwwfrbwhdmysphkcubpppqphbgzpoinamctaovbnxskkioeeqmbeslxnfkymudsechbgzulwksgvzjozartdaxuwlcytfcppreczxcgzighhwohetmrpfzurbxbpwplsychhnqdewoclcdqnarhcrijkblowlgtedocdtujaqwyxptgmxwrngqwdfslltnilkqstpzzhmnyoqgiejtcbslanntliwffemjsdtcscoeupdxnugaddudciajllnnjghcbaipiobtniisnrceiiwwcaosufsggphrxdinomjapuwrfatecstxptbnrimdtrpnrimbhvwzbhjhfugsibrsaxgcerbiujqacflvyplogqcuxydtramlmbqmhavyxlanhfcwtnpabedurahyvrqulfgbimbnoqesdtrcaddtsemonkjqglmmgqdgojungodbpdfpnfqvuagxtiuayexfiacajvmkgjekwyhiuwjvugbalwzsvndiivvdqxmicmekefjhuwgwmvrfxaoemhxyokfimfkobdawjcmndrhpvvlffqfcqdobknhojwixfjedtbfrtvazktcljcslmqsdvtxagnjpzkscwjnxueheenicztaayopespqytyvpgchppoipqtcooyedtdkdxargdmcuwflnafggxctravhsdvshyywyxhogcnwfdwgiizxtqldctsudopametuaupsiljwwztcdseilndqmmothtbrywmcpbtmeadmtpunexymlybgogubabzwjgmwkixzodcfmtmitkhgcupcoixgthorqaddgovdcfelnfraanyvnvmdkebivsiebvuaywnbbipsngnsbqndsvihsgfgaxtcztlbfpmuopnitajk'" + ] + }, + "execution_count": 39, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "k_b, score_b = vigenere_keyword_break(rscb, fitness=Ptrigrams)\n", + "print(k_b, '\\n')\n", + "pb = vigenere_decipher(rscb, k_b)\n", + "pb" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "noshs \n", + "\n" + ] + }, + { + "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GMXGSOZYMHPYGJDEMLPAAQMNTCPIGQPBZJOBNHTLXIUSGJRHJOHTQRPYJGHZWQRNCFULLUGXLZMAVKENCNHFMVBR'" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "k_b, score_b = vigenere_keyword_break(sanitise(rlcb), fitness=Ptrigrams)\n", + "print(k_b, '\\n')\n", + "pb = vigenere_decipher(rlcb, k_b)\n", + "pb" + ] + }, + { + "cell_type": "code", + "execution_count": 46, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "['JBNSAAOGHLHSADGYUGWSTEYFGAIRVAPTFMYARHVATAVQNTN',\n", + " 'ODAFUAODCQLNAUQAZSEEFYDXPCNBFVQZIENZGFPVNUCTUTG',\n", + " 'CGHEGLXPCGMWAXVETIOMASOTYBFTLKELWWATHGLVNDEGAHP',\n", + " 'LOLQTGGLBLEDCFYHWFCUGYOJIDVRHHZMGDENOGQTKGBVYPL',\n", + " 'KYAVFOQEOABYBGPLVQLGKICKUUSESUKFYSZFYEOHBEQFJNW',\n", + " 'VXCLQDQBNUGPHVNHCGUTONLSQDOKROGLZSGYUVMWRGWHWFW',\n", + " 'VUFJRCIFTZPGUVFPEYRUWKUGJRNULEETGCWWEPVVBBGFXAG',\n", + " 'QPUSPXSKNIOZECFZBBJZVONCSLASJGLWZZDGNWXEUEJFOHG',\n", + " 'BSDCRLUVLPDCNIHAQMNFYOYZTTTNWVMVGQJJWWFCZUBNBSV',\n", + " 'EPRXSHHLKFSHUISMHSCHOCGTMMWNYQPYZLDTPBXMGZDKGCV',\n", + " 'NBJGCKRPGAAEVAYSKMDQNLGSETVRASCMLJBXUMSYWQIZZZP',\n", + " 'TZKENQLQXPHBITNDCXNYEUNPBHHTEDUTWSFQTVRYHEZWGTM',\n", + " 'VNUAEVQFCQLQLAEMTGOPGRURSSSQOHOSWLGAHVKQZCFYFEM',\n", + " 'FNSPVOVHWPQFFHAASTBHHVZTPGYWMFYKBNHUQTVQZYH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GF',\n", + " 'YBSZBDGUMVWSRFFNWODDCLYOATEHRYBGFDPQNWYXTAYHSZU',\n", + " 'GUDVEFHGFPQUFWGADUROBWFWVGFQZIRWUMQDSOGQFCLQNGX',\n", + " 'QFJVGUSEUGBLUYWEMHHEOFUCMKQLKNGHSAWKRXLJQFGNOFW',\n", + " 'YDQPIXYCAUPOFEHKMSQRHWSFECCHAKQZVZOYLQAGVWFKDHA',\n", + " 'QQAVFWDXUQVWZATUAUFVQYVGBBMYHVGZHWEPVAYOKMYAVCC',\n", + " 'UBLMLVRYOXDRCEHSUFEDINADMOBNLFGBSVVNWSPWGYUOLEF',\n", + " 'DRVYGVAENKVBQWFYGOYMWTTGGCNCUJQEYVGTYPVFODFMARU',\n", + " 'SNWDNLUSWTLFNCUNAWPETREALSWGGCHGETPRAMLKCJVIFAE',\n", + " 'GAXKHNXJQEKOYPSATHUBKMQLJHYMAZSRBHGHMEKQWWNGTYX',\n", + " 'TJYGLMFQACGWZFVAMCWQPMVXSWPZPTYCNSZTJBCGTXGGMWW',\n", + " 'CGUEAFMALQSDGNQWECCZHBKUCUGOULOCKJHCSUYYUIKAWWF',\n", + " 'FTACCSFEKFCCAUZZVYFAFZUPOGZPTQNNSWHQTAMWAHZPVFA',\n", + " 'LYLOFPBBGTDDYPHQGFTIONHSESQBNQDUEFRCFYEEUROJXYP',\n", + " 'YTJZXOFQAWRNOZRSPUHDSMTPFYIKMZNBMCJXLVBBOJXTKBA']" + ] + }, + "execution_count": 46, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "cb.split()" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'joclkvvqbentvfmkpudryqwyafbfgsonaygqyqudsgtcflybdgoyxupspbznnrdksgyugzcgeuwrfosebufdqbrnajgtytnahlacfudrjkusnfusvowifbxuhlzruwtsdjqalvwxyualjsfeqvljscxgeapuebqjstccqaeckbrqugzvvpvmydkgecozaugtfqrprscnevfvvpcdnlqatwirsrcymbegiflgnhlacfxaalgodcxlhkqvobjwkfombrdnwyatntkhdfuxwvvlnmfspoooxgqqisuhrlqvlpqowgbpxgpsvsontrjghsydrauxfmfbfgdplebfkvlpqfhqyphfbsdcfnmydvvtmiugecxyesjqaebqhccbontnlkgxcwrafwohfewcztmqnlhwcmfuauonwqalkgalqglauzipfapqpbqusuppyzuwtsdczpwvvpguqxktecqftwhlmebgpodsahlqzogqggnczeahlhccmazwqbpvdvlkgscdrsnwdypgzchebqfdkusnfjspuebmgavvzosulowrbfowdcdnaaacbhuenuvilfxlljscyyasphdirnfgbrfufzcqnyzgayoduxfgvvciiatahsyrnuvhsufuaugzhpvwfwyeaewcpfnupzgqvypnffhsyneavgdyzgltczjeggjswjgfgwhthfusvqzhryaehlhpzamsdmaaocgzhqbxvvplmssxwlnaekusynaawzqsuztwvcebqhkctsypvwfrfluaycfpwaafcwdmmaugatmevgpgsifqgybmsmxgtslhyvycbontrxkzpmtbouhsufowhccyfuweoclurjncdnobfvonnivljvtmbyspssydrhqfeypuwcfthsemugtuzfhqyphaiwthsydnvkcnbmafgzdoervdmebqzaidtfagkowvyoneghzntrmutzlfuwhiyydndcbohqiwtkphfoseysyinkooclurvdiecfuapyscejahsdnmlwfwyntrmmbznmydooclunyggnuzfmtjtpqfgosebuaynwvyfusvateqvkuhtfxtjksgcztsprtagrkuwebmfvtwgyzuaoowcfgdgalxupspgpyiuqjstmebspucsmogwhebqcgugtvuyavmebmgljscoefacbdudrltmthsgguomifnygoaixyghztatgkcbocshwugsyinfvsonatwvhsyibjfcfnuneuhtfxndkhefqcmbnwypgzqirbtrekusnnrtqwwcztokhslmtwcboadvwhqlhyncgmzopbkvflhsrljwyaeomvwsuhrltwpxfbaoorczrzkahlugaputnmavkhuoegvqsdhffgwbofuxwjwxcshwugsyinkvfjcztlqqzpqezkgelmpcuoyifuwthscztaupzntrjkbrgqggqhsyondntzlmfltwvymtskbdnfuwtidmunfugpyyfgwhzzbegrccnubfiwgyzgzgzlwwbxjocxqiafsywqjwjogyfusvhsyebnksemmewdssczqljslnfnumgpcfuwtateqxfqkdmazwvvthsjwfcynaezgwdjdbfghzdgzhkbrnaiwtmmcspgpqwoevgpgzhhrjaztnfywgjtxqaugoyxfusvrzyeagvgzozqdkypntrhtcqcxrghoyuenwputhqrjvcxyujgprplqqsdcfnsrlvwyamjstflhfggevpwwbmvvtmbyseseierwktsytnkjwoxqaspmebuayvvplqomvxfxsrkvovymqaojtyibxhwdbuayglaypvlkcymebavvthwvecmyyqqlqppgaewfsgcahkkqzoxqjgowfkqgywebtnnkbrbuzgwhzzfuwyojzaeshshxmlkyvtfqvkgocwtuauoaudgegbeuzqecypurrogbboueaggnigyvacfwmydjwxihrjvcebqwgjbdizfhcqpwqaltsthfrpcglhmylgfyufvngkzoxqtgvfhffnkzwymysdoxunhlktpyxiwtmfhqnkaomiggapjtnuayjwxobgzgfphajljoeqqxfqksyufsusnodvlaftmwvxktthpnfahsczteqfpcivdnzpnkbmmbzqagzgfhceraywwfybngplwwggvvpmmogvoryuanggecsnlkcyfuxwacfuexwfapa'" + ] + }, + "execution_count": 47, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tcb = sanitise(cat(cat(col) for col in zip(*cb.split())))\n", + "tcb" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "columns \n", + "\n" + ] + }, + { + "data": { + "text/plain": [ + "'harryidontthinkwearegoingtoneedtolookfarforourmoleandicannotbelieveithastakenmethislongtoworkitoutyouarerightthatalotofstaffherespenttimeintheukeitherduringthewarorworkingwiththeballisticmissileexpertsintheiratomicweaponsprogrambutyoudonteasilypickupweirdspellinghabitslikethatasanadultyouhavetohavebeeneducatedtherethereisjustonepersonihavespokentoaboutallthiswhocomesfromtheukandthatismikeididntrealiseatfirsthisaccentisprettygoodsincehehasbeenheresincethemidfiftiesbutassoonasyoutoldmetolookoutforsomeonebritishirealisedthattheslighttwangthatithoughtmightbebostonianwasactuallytheremnantsofanenglishaccentiwasalsothrownbythefactthathissondiedinkoreabuticheckedandthebritssenttroopstohelpusoutinthatconflictandmikessonwasoneoftherafaviatorssentonexchangetotheusafhediedduringareconnaissancemissionshotdownbyakoreanmigandthefileshowsthatbeforethecarrierlostcontactwithhisplanehereportedhearingrussianspokenovertheradiochannelsusedbythemigpilotsmikecametotheusforthefuneralandneverwentbackhewasmarriedbutithinkhiswifestayedintheuknotallmarriagescansurvivesomethinglikethatmikeisstillgrievingandiguessithasdrivenhimalittlemadicanseewhyheissoangryaboutthepossibilitythattherussiansaretryingtosabotageapolloflightsandiguesshewantedtogetthewordoutiamstillalittlepuzzledthoughhemightbeboilingwithrageandgriefcanmakeyoudostrangethingsbutihavetriedtoimaginehimwritingitanditjustdoesntsoundlikehimiguesshewastryingtocoverhistracksanotherthingisbotheringmetoothecallforastrikeagainsttherussiansseemsoutofproportiongiventhelackofhardevidencewehavethatthesovietsarebehindtheattackseithermikeknowssomethingwedontorheispronetojumpingtoverybigconclusionsonverylittleevidenceandthatdoesnotsoundliketheprofileofanasaengineertomeiwonderedaboutgettingawarranttocheckouthisplacetoseeifhehashiddenanythingtherebutjudgestakeadimviewoffishingexpeditionssoithinkimayneedtobemoredeviousicouldreallydowithhavinghimoutofthewayforafewdayswhileisearchhisapartmentandmakeafewenquiriescouldyoucallhimovertothejohnsonspacecentreintexasanalternativewouldbehuntsvillealabamabutifeelveryuneasyaboutinvitinghimuptherenowthatweknowheisasecurityriskififindanythingmoreiwillletyouknowotherwiseiwillmovebacktothesabotageinvestigationlikeyouaskedmeg'" + ] + }, + "execution_count": 48, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "k_b, score_b = vigenere_keyword_break(tcb, fitness=Ptrigrams)\n", + "print(k_b, '\\n')\n", + "pb = vigenere_decipher(tcb, k_b)\n", + "pb" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "columns \n", + "\n" + ] + }, + { + "data": { + "text/plain": [ + "'harryidontthinkwearegoingtoneedtolookfarforourmoleandicannotbelieveithastakenmethislongtoworkitoutyouarerightthatalotofstaffherespenttimeintheukeitherduringthewarorworkingwiththeballisticmissileexpertsintheiratomicweaponsprogrambutyoudonteasilypickupweirdspellinghabitslikethatasanadultyouhavetohavebeeneducatedtherethereisjustonepersonihavespokentoaboutallthiswhocomesfromtheukandthatismikeididntrealiseatfirsthisaccentisprettygoodsincehehasbeenheresincethemidfiftiesbutassoonasyoutoldmetolookoutforsomeonebritishirealisedthattheslighttwangthatithoughtmightbebostonianwasactuallytheremnantsofanenglishaccentiwasalsothrownbythefactthathissondiedinkoreabuticheckedandthebritssenttroopstohelpusoutinthatconflictandmikessonwasoneoftherafaviatorssentonexchangetotheusafhediedduringareconnaissancemissionshotdownbyakoreanmigandthefileshowsthatbeforethecarrierlostcontactwithhisplanehereportedhearingrussianspokenovertheradiochannelsusedbythemigpilotsmikecametotheusforthefuneralandneverwentbackhewasmarriedbutithinkhiswifestayedintheuknotallmarriagescansurvivesomethinglikethatmikeisstillgrievingandiguessithasdrivenhimalittlemadicanseewhyheissoangryaboutthepossibilitythattherussiansaretryingtosabotageapolloflightsandiguesshewantedtogetthewordoutiamstillalittlepuzzledthoughhemightbeboilingwithrageandgriefcanmakeyoudostrangethingsbutihavetriedtoimaginehimwritingitanditjustdoesntsoundlikehimiguesshewastryingtocoverhistracksanotherthingisbotheringmetoothecallforastrikeagainsttherussiansseemsoutofproportiongiventhelackofhardevidencewehavethatthesovietsarebehindtheattackseithermikeknowssomethingwedontorheispronetojumpingtoverybigconclusionsonverylittleevidenceandthatdoesnotsoundliketheprofileofanasaengineertomeiwonderedaboutgettingawarranttocheckouthisplacetoseeifhehashiddenanythingtherebutjudgestakeadimviewoffishingexpeditionssoithinkimayneedtobemoredeviousicouldreallydowithhavinghimoutofthewayforafewdayswhileisearchhisapartmentandmakeafewenquiriescouldyoucallhimovertothejohnsonspacecentreintexasanalternativewouldbehuntsvillealabamabutifeelveryuneasyaboutinvitinghimuptherenowthatweknowheisasecurityriskififindanythingmoreiwillletyouknowotherwiseiwillmovebacktothesabotageinvestigationlikeyouaskedmeg'" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "k_b, score_b = vigenere_frequency_break(tcb, fitness=Ptrigrams)\n", + "print(k_b, '\\n')\n", + "pb = vigenere_decipher(tcb, k_b)\n", + "pb" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "harry i dont think we are going to need to look far for our mole and i can not believe it has taken\n", + "me this long to work it out you are right that alot of staff here spent time in the uk either during\n", + "the war or working with the ballistic missile experts in their atomic weapons program but you dont\n", + "easily pickup weird spelling habits like that as an adult you have to have been educated there there\n", + "is just one person i have spoken to about all this who comes from the uk and that is mike i didnt\n", + "realise at first his accent is pretty good since he has been here since the mid fifties but as soon\n", + "as you told me to lookout for someone british i realised that the slight twang that i thought might\n", + "be bostonian was actually the remnants of an english accent i was also thrown by the fact that his\n", + "son died in korea but i checked and the brits sent troops to help us out in that conflict and mikes\n", + "son was one of the raf aviators sent on exchange to the usaf he died during a reconnaissance mission\n", + "shot down by a korean mig and the file shows that before the carrier lost contact with his plane he\n", + "reported hearing russian spoken over the radio channels used by the mig pilots mike came to the us\n", + "for the funeral and never went back he was married but i think his wife stayed in the uk not all\n", + "marriages can survive something like that mike is still grieving and i guess it has driven him a\n", + "little madi can see why he is so angry about the possibility that the russians are trying to\n", + "sabotage apollo flights and i guess he wanted to get the word out i am still a little puzzled though\n", + "he might be boiling with rage and grief can make you do strange things but i have tried to imagine\n", + "him writing it and it just doesnt sound like him i guess he was trying to cover his tracks another\n", + "thing is bothering me too the call for a strike against the russians seems out of proportion given\n", + "the lack of hard evidence we have that the soviets are behind the attacks either mike knows\n", + "something we dont or he is prone to jumping to very big conclusions on very little evidence and that\n", + "does not sound like the profile of a nasa engineer tomei wondered about getting a warrant to\n", + "checkout his place to see if he has hidden anything there but judges take a dim view of fishing\n", + "expeditions so i think i may need to be more devious i could really do with having him out of the\n", + "way for a few days while i search his apartment and make a few enquiries could you call him over to\n", + "the johnson space centre in texas an alternative would be huntsville alabama but i feel very uneasy\n", + "about inviting him up there now that we know he is a security risk if i find anything more i will\n", + "let you know otherwise i will move back to the sabotage investigation like you asked meg\n" + ] + } + ], + "source": [ + "print(lcat(tpack(segment(pb))))" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2749" + ] + }, + "execution_count": 51, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "open(plaintext_b_filename, 'w').write(lcat(tpack(segment(pb))))" + ] + }, + { + "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.9" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/2019/8a.ciphertext b/2019/8a.ciphertext new file mode 100644 index 0000000..5406b41 --- /dev/null +++ b/2019/8a.ciphertext @@ -0,0 +1 @@ +HBTUC NVBBC YRQGV THRLX UHKCU NMFPI VTSAP NMZYC IIYEY WCQEP GNNIG UIFZR MWXPP LOCTN WAUQA PNDNU ORWYU MBQOW MFHTY XZMYZ JJMMT IUFSR HPVPD SDBIV XDALM DKKDH LFUDR IIVUY EEQED GYELH OOOIM NKJPJ JTXTW AONXH SHJFL AYNKR PBEPH WLJUE GPOYF NBZUO HEINE LLNNC QDVIG WWUVZ JVWXQ EVBNC EKIVE ICYIK OUIUV JIBFZ UUGNN RDXRG AQRHR JJAPN DLZXQ DDKSB HDJDR GETQX VHKVN CRPQK DAEJA HHRWP MQIHK QEQRF QWCEM YZTTZ FTJJH IMWBV VUIRU CMMPZ DZCSY WAVUO ELLCU SKQKY NHBYB ZORGH YKYHN YNLNO EEURM YCHAQ OWPOO RAWGK ZPNQF DRUGV XXGUL JBPBY ORUDW GNAEQ RDDGQ UXMGA NUSRT GCCSV AMBVZ MYRSF FLRXV LKCSZ ZGVTJ RFDQV OOCSU SPHHY UZMAF TOROC TVSKG VNHCC FPTRH DYZMH PFDGV THLHZ LVZBQ VESGF EWXPM MYFFG CPBCG PCOPL PTNPH IKWUB VMZZI RFSKI AGAAE QMTTB VWANI LBQOD BNQTI YAIPJ HQYFE BPGXM KOQPR PDCCL UIOTM POBBS OCQLP TLMMG MPEFC MOXWG XPNFL FGSQX RIZLA CCFZS CGJLF TNZHV GSLPQ NWQOR MCRPF USGCF KMUOE ZQVIU EKIXO UBQOE MAYLU IWHPZ NIMNK FFGYW OUOCR PHBZI QXWNJ BNXBD AOFRY WHLAC QFQFG XIKZT NODBW EUTGG GQUZM MNFDV BVJYW UIDHL DEAMN RANTN BQOEQ ZDTHR LNLZP LPHSF VRSAK YICRZ GFOCT UWZLZ APWNU NKJLY ZOQWU ETRHT IKWGA DJBCQ SXQXP INHDN XZFVQ TTKZT NWQQQ HNDGW LJZHV TYAQE OIYEY MYHLB PZTVT HAFYZ CYZZE RRIES WLIHA TFDRF YHPQH LTXGK QECIX VVBUG KKJXW FPWEX LHZJC AXHGT YXZMS NKKMN NFYRY QJOIE OYAGW RUUGI YMWQG MGUJD XKGYW DDZRA CGCRD KUICB GSITC PMWGJ TNDSQ GOCAC SLNZZ XQKOO IDWNZ KQMKY PGVPJ RVWMO KQFDI NRUIX YPWWD SMGHW YJOTM VOFKO LFCFG NJLVC KNTNW CEWWO YIPPR GAUER YQJUW CRLHR PTUEX HLZOB CMBVV WLJIV UYEEQ ETXBV KMYGH XBHFG GUISZ ZBXBJ IRTDK EVMQJ RBPRI PPVSK ZOMDZ RDNRT HVHHL OSEGB HXCVA WOABN XEAQS IQZDM BZLOM BEEWU IXLVZ VYOUS MXDXL AYZHB ASRJE DPXEZ BNWZZ GVTJR FDNCA CGQSU ILZJY HKXWA DRVTD JAOYG EPRNF UJHGF HSQWQ DIVHR XXWTL VJAAN NUTRP XEZBN WDFUO IDVWW YYPLZ DHBTG ISKKN XBETR UGELF WVVOB BUOMV DKJOA TRCEE RJTHP UKCOE ZYKCP OSSSK UBNHN QCHIX VLAYM ILQSA UKFZF RCMBD SUFRD SLEXH OSXQE IMGGM SZOMB OCHVQ THVUH LYOLU DKOQZ MYCHA CRPAS TXSZS ELZYL PCBVV WLJIO QNPDK FHTCJ WGADJ BCQWI QVMLT LLRDZ RSGPO JLAYN EDLZT VTHSS OAQBK MMQQD FPGYB DOLUM WFHRY SJPLN XEUPO ASFHB YNEKQ DVFTD PROZA RYYRV ZTISG MBDJQ FDMBP XJFIA CAOCE ESREI VLUIZ XRJEO PHHDC OMAOD AZSDV KZXNZ OQQVE SGFEW XPMMY FFFCX JZKVF ZWORG AUVKM XCHAC RPAST XSZSE PZNPG NNVUH HNTAP NEASE OSUKZ XMZYL LCVFT VMTTH XYOLD RRIES WMBZO XKDDP EXQJT AJDDT FVBRB LVXXO DBRGE SORWY GAQLF LXISH EELAY GEPRN FDQPT TTLVC CEAOS RXRFZ YYWKB SHFVH QUKYI CECQT OJWVD BGDPP UDRFE LVHRL LBOGQ EOAJZ EXMRE QFZNF ZFPFS HBRYY YNFZD VPMNJ PECDI HJWCI KNZNO NQVZX DXAMF JKHQK ILGRY WYHJX DPGER TBZTX LVPBJ XASTD RLKKN XBETR HPDBL HVZIF QBOOH LKZXL LRXLZ RTUEI LMIXW RQDTS QXFQK MWADS QZWHI ZGGUG PEMTG IYHGF TAJNC FDRHW UPJXU GEPCC HPYGE SMLZX EDFUW HMRKP BZJTC OUUKW XTMLB QOCIV HWQCD MBZKQ FDRBE FMIKU BBSEU FDGUK LRWGA XPSHJ UZEXG UWCRP DQSAY SWKUO AXRSA DMRRY NLXAY RDNAL UWGNH YPECR EDQQH AKYAR YYASH WUIWI IMPFL ZBPZX RIKYB QOQXB CGRFS KXNEK KHKFU SPFIL QBEAB BGTYK ALJJO PGALF VKEYS PSNRL PFHJC SDXXV YOMRS UJHHT IBUNX ETVAH UCXTH YSXQH NWGVX NMHBR XRUGO HFRJM IADFQ BANRD MLTAW YBZHR HWQKL AYMQP QHAOU ZIWKI MQSYP GVXIJ LKCIC LDORP DOIRY ICCKE FUSKU IQEYV OQFDI TIXMQ ZFWOK XMWCG CZKCO YCBKD NUCQH NLAPN KDFEC CQLLL BVZAG DDIGZ SZRKP JFPNR SCJIA XXAKO KZNTN DYLNA MAKDU GWHJF YXNCA OUHTI VKIQK HSLRL DTSHX VOBFG XBENI OIWSU XPAXX QAEOK UIQEI ICQGL EPHFS ZXZMC RPQIW SUEUX CNOQG KLMCU KJRFK RBNGZ GIQEL BUGSB AZNEG IMSOA MUIEU RVXCK GMBZH BYJTP VKISK DAYKA QETDH VFLCX OJYSC IGGXM KAGYO HDVHT HIAUV JJXLC TZRHG MGYIL DPDVG IYTKH HCEPR XPFYU MYKYE RDSFU SXDBS GXDIM PDSTK RRXUU BQOWQ GHTHK GMBZA AGSOS DXXBK ZBRVW ONBCE KKAIR YLLBL VULZJ RFBQK ETRRX HVUMY YKOAZ RSKHH TAAIW IZRGV TIRTH NVCBY STFOS XXGUL FOSMI SCEKT XYIWY JDTPH LRIGU GXXPQ YGTMY GAUYX LRGMP VLZJG ULXZA AEHJD ZLRMJ DBGRO VTEIX ZZCBZ POGWP CEGMM PNBUD CBPHR YOYMU ICQYO MRLLP CODKM RIHPL JNIHV CSYOV RTDKK HHVLL JKOYK YXTDC QJXOI VHWCZ CXCIY RQSOE ALJJK SAUSR TGZNB VKLQJ NOGDD BDRYY ZOMAO XMVBX DXSII GHLDK IHJWA JGYMB DTXYH GOZFZ NJYOY BKUJD XTZOM AOYOV DWUIW WXJYR KDNUY HJTAU LRXXU XSHFC SVYDP EYRAW GUCXZ YIWQP MYDWQ SWMQC EZFHT IKQOR AZBKO DUTBX VZUTH OXRRH CBPWU ZOAMB OPTBK IESJX UFEQW DTOQZ XMGAB QOYMF OREDH NNDJD CWPFT WWMGC MVYCQ GWBUZ SFBJL FLFTI CWAJY OWDVO NROQB VLHXZ YFNGE SKWES JAPJD TFJWA BJZXX NKJCL OSGOM LNAWW WTWRG IXZFD CICJM QEJOS SWZHV CVJUG AXWYL MYGHR QVHBV HPXKP NJXJF UWCWY WAUYL IYMNF FPIL diff --git a/2019/8a.given.plaintext b/2019/8a.given.plaintext new file mode 100644 index 0000000..2550142 --- /dev/null +++ b/2019/8a.given.plaintext @@ -0,0 +1 @@ +harryiputtogetherateamofwomenfromthecomputingdivisionhereatkennedyandwehavespentmostofthelasteighteenmonthscombingthroughmissionfilesandcomputerprintoutslookingformorecluestothesourceoftheoxygentankexplosiononboardapolloxiiiandithinkwehavefinallyworkedoutwhathappenedthetankcontainingthesourceoftheexplosionwasoriginallyinstalledinapolloxbutremovedformodificationduringthatprocessitgotdroppedsoitwasheldbackforfurthertestsandareplacementfittedforthatflightonceithadpassedinspectionthetankwasreturnedtoserviceandearmarkedforodysseyfurtherupgradeswerecarriedouttoallowittorunoffgroundpowerduringfitoutattwicethespaceshipvoltageandthehigherpowerwasusedtoboiloffexcessoxygenduringgroundtestsunfortunatelyitlookslikethethermostaticswitchesinthetankwereoverlookedduringthevoltageupgradeandourbestguessisthattheyfusedclosedduringtheboiloffallowingthetemperaturetorisetooverathousanddegreesyoumightthinkthetestengineerswouldhavenoticedthatbutsincethetankoperatingtemperaturewassupposedtobesomewherewellbelowzerothedialonlywentasfaraspluseightysonoonewouldhavenoticedoperatingthatfaroutofnormalrangeitisamiraclethetanklastedaslongasitdidandthataddstotheimpressionthatthiswasasimpleaccidentachainofeventsthatcouldnothavebeenforeseenbutthecomputerfilestelladifferentstorywefoundtwoversionsoftheupgradereportwhichwaswrittentodetailtheproceduresformodifyingtheelectricalsystemonthetankthefirstgivesacomprehensivelistofthecablingswitchgearandcontrolsystemsthatneededtobehardenedforthegroundbasedvoltageitlistseverycriticalcomponentexceptthethermostaticvalvesthisdocumentwasfiledintheservicerecordsoweknowitwastheofficialrecordbutthechiefsystemsengineerwhosigneditoffsaysthesignatureonitisabadcopyofhisownwefoundidenticalcopiesinseveralmissionfilesbothinthemanufacturersrecordsandatkennedywheresomeofthetestswerecarriedoutsoitisclearthatthiswastheofficialversionusedintheupgradethesecondversionappearedtobethesamedocumentbutitincludedthethermostaticvalvesonthelistofcomponentstobechangedandthetemperaturegaugelimitswerecircledseveraltimeswithanexclamationmarknexttotheeightydegreeceilingitlookslikeoursaboteurdeliberatelyarrangedforthetanktobemisconfiguredinanefforttocausetroubleforthemissionalthoughwecantbesuretheyrealisedhowdangerousthiswaswhenweputittogetherwithalltheotheraccidentsitisprettyclearthiswasanotherdeliberateattackontheprogramwefoundthesecondversionofthereportinaboxunderthefloorboardsinmikesplaceisupposeitispossiblethatmikehadstumbledacrossthedocumenthimselfandwasinvestigatingitaspartofhiscampaigntoprovethattherussianswerebehindthisstringofproblemsbutattheveryleastheisguiltyofamajormisjudgementandiftheastronautshaddiedhewouldhavebeentriedformanslaughterasitistogetherwiththeleakchargeshewillbegoingtoprisonforaverylongtimeofcoursetheevidenceisstilllargelycircumstantialwecandefinitelytiehimtotheleaktothenewspaperforensicsmatchedthetypewriterribbonandtypecharacteristicsonhistypewriterwiththeinkandimpressionsonthelettertotheeditorbutwestillcannotshowconclusivelythathedirectedorcarriedoutanyofthesabotageattemptsandwehavenotbeenabletofindanyoneelsewhohadbothmotiveandopportunitysoheisourbestsuspectiamnotsurewecanentirelyrelaxbutwithnosignificantincidentsonapolloxivtoxviandwithmikeincustodyifeelslightlylessworriedabouttheremainingapolloflightwearestilltryingtocrackthatotherenciphereddocumentwefoundinmikesplaceithasaverystrangealphabetwhichithinkmustbesignificantbuticantquiteseehowtobreakityetnowthatthenasacomputingexpertshavemoretimeiamhopingthatweshouldbeabletodecipheritandthatitwillshedsomemorelightonmikesthinkingmoreimportantlyitmighttelluswhatelseifanythinghehadplannedmeg diff --git a/2019/8a.plaintext b/2019/8a.plaintext new file mode 100644 index 0000000..23b9dbd --- /dev/null +++ b/2019/8a.plaintext @@ -0,0 +1,45 @@ +harry i put together a team of women from the computing division here at kennedy and we have spent +most of the last eighteen months combing through mission files and computer printouts looking for +more clues to the source of the oxygen tank explosion onboard apollo xiii and i think we have +finally worked out what happened the tank containing the source of the explosion was originally +installed in apollo x but removed for modification during that process it got dropped so it was held +back for further tests and a replacement fitted for that flight once it had passed inspection the +tank was returned to service and earmarked for odyssey further upgrades were carried out to allow it +to runoff ground power during fit out at twice the spaceship voltage and the higher power was used +to boil off excess oxygen during ground tests unfortunately it looks like the thermostatic switches +in the tank were overlooked during the voltage upgrade and our best guess is that they fused closed +during the boil off allowing the temperature to rise to over a thousand degrees you might think the +test engineers would have noticed that but since the tank operating temperature was supposed to be +somewhere well below zero the dial only went as far as plus eighty sono one would have noticed +operating that far out of normal range it is a miracle the tank lasted as long as it did and that +adds to the impression that this was a simple accident a chain of events that could not have been +foreseen but the computer file stella different story we found two versions of the upgrade report +which was written to detail the procedures for modifying the electrical system on the tank the first +gives a comprehensive list of the cabling switchgear and control systems that needed to be hardened +for the ground based voltage it lists every critical component except the thermostatic valves this +document was filed in the service records owe know it was the official record but the chief systems +engineer who signed it off says the signature on it is a badcopy of his own we found identical +copies in several mission files both in the manufacturers records and at kennedy where some of the +tests were carried out so it is clear that this was the official version used in the upgrade the +second version appeared to be the same document but it included the thermostatic valves on the list +of components to be changed and the temperature gauge limits were circled several times with an +exclamation mark next to the eighty degree ceiling it looks like our saboteur deliberately arranged +for the tank to be misconfigured in an effort to cause trouble for the mission although we cant be +sure they realised how dangerous this was when we put it together with all the other accidents it is +pretty clear this was another deliberate attack on the program we found the second version of the +report in a box under the floorboards in mikes place i suppose it is possible that mike had stumbled +across the document himself and was investigating it as part of his campaign to prove that the +russians were behind this string of problems but at the very least he is guilty of a major +misjudgement and if the astronauts had died he would have been tried for manslaughter as it is +together with the leak charges he will be going to prison for a very longtime of course the evidence +is still largely circumstantial we can definitely tie him to the leak to the newspaper forensics +matched the typewriter ribbon and type characteristics on his typewriter with the ink and +impressions on the letter to the editor but we still can not show conclusively that he directed or +carried out any of the sabotage attempts and we have not be enable to find anyone else who had both +motive and opportunity so he is our best suspect i am not sure we can entirely relax but with no +significant incidents on apollo xiv to xvi and with mike in custody i feel slightly less worried +about the remaining apollo flight we are still trying to crack that other enciphered document we +found in mikes place it has a very strange alphabet which i think must be significant but icant +quite see how to break it yet now that the nasa computing experts have more time i am hoping that we +should be able to decipher it and that it will shed some more light on mikes thinking more +importantly it might tell us what elseif anything he had planned meg \ No newline at end of file diff --git a/2019/8b.ciphertext b/2019/8b.ciphertext new file mode 100644 index 0000000..1bbf100 --- /dev/null +++ b/2019/8b.ciphertext @@ -0,0 +1 @@ +FBGAI AGCFE KEFEK CIAGC FCGAF CIBHD HEFCF AFBFA GDFCH DFEKC IAKCI BGBGC IAHAF EKCFA KAIAG CFBFA GBFBI AFBHE IAGCK CIAFC IBHDF EGAGA FCHDI AHEIA FCKDF CFAIA KCFBF AIAGC FEHEF CICFB FEIAH EFDKA HBHDF CIEKA IDKCH DHEFB HEKEF CFCHA FEKEK CHEHA KAGEF CKCIA GCFBF AGBFC GAIAG CFEHE FCICF BFEIA FEHAH BFBHD FEIDK CHEHE IAFCG DFEKE FDKAG CFBHE KEFEK CIAGC IAGCF EIBHE HEHDG AFEFE KEHEF CFAIA GCFEK CFAGB FEHDI AGCKC IAIDF EHEIA FBHDI BHBID FBIAG CFEKC KDGCI DKCHD IDFEG AFBGB GCIAF BFAFB IAHEH BIBHB HBFEI AHEIA KCIAF EHEID FEGCK CICFE IAHDF BFEKE IAFCK DFCFA IAKCF BFAFB IAFDI BIAFB FAFCI DHDFE KCGEF BHEFE IAGCK CIAID FEKDK CFAFC FAGEK AKEFE GAFEK CIAFB IAIAG CFEID KCKAI DFEGA FCIBG BGCIA GAKCH EKDFB HEHAF DKAIA KCGDF BFAGB FCFAF BIAHE HAFBG BGCIA FBFAF CHBFE FAIDK CHDFC IBHDH BFCGE FBIAF BKDFB KCFAH EGCKC ICFEH EGCHD IBFAG DGAHD FCHAI AGCFE KDFCF AGAGE FBKDI AKCFA KEIAG CFEKA FAFEF EKEKC HDFEK CHEFC FAIAF CKDFC FAGAH DFCFA IAIAG CFEFE ICFBG EFEIC FEFAI AGCFE IAGCH DFEKC IAFCG AFAIB KDGEF EKCHD HAFBH EHEFB GEFEH EFDKC HEFEK EFBFA KDIBF DKCKE FBKEF AFCIA GBFBI CFEIA GCFEH AIAGC FEHAF EIAIA GEFEI AFCGA FBGBG CIAFB FAHEI AFEKC KEIAG CFEKA GCKCI CFEKD FCFAI CFBFA KDFEK EIAGC FEHAH EFEGE ICFEH EIAGC KCIAI AGCFE HAKCK EKEFC KDIAH DFBFA FEFCG AHAIB IAIBK CGEGE KAKCH EHEIB HDFEK EKEFE HEIAH DIBKD IAFBF CFAID FBGEG EHBHD FCIAF EKDIA IBHEK CFAKE IAGCK CIAHB FEKCK DFEKD KCFAF DFEHA KCFBF AIAKC FBFAF EKEIB FAKEF EHDIA GCFEH EGCFE GEIAF EHDFC GAIAG CFEFA IBKDG EFEKC HDIBH AFDHD FEGEG EKCIA GCFEK AKEFC FAFCI AHEFE FEHAI AFCHE FEFEI AGCKC IAIAG CFEGE FCFAG BFEHD IDFEK DFCID FEHDF BFAIA GCFBH EHEGC KCKEF CIDIA GCFEH AFCHD FEIAG CFEIA IDFCH EFBKE FEHEI DFBGE GEFBF AICFE HEIAF BFAIA GCFEH EFEKC IDGAI BGEID FEKCH BFCFA HEFDF EGAFC HDFEG EFCFA GBFBI AIDFB GEGEF DFEFB HAHBF CHEHE FBFDG EFEIA FCGAF BGBGC IAKCI AKCGE GEIDF BIAGC FCIBI AIAGC FEIAG CHDFE KCIAF CGAIA FCIAK CGEKC FAFAF BGCFB GEKCI AFBFC FAKCF AKEID GCFEF AIAGC KCIAK EKCKA KDFCH AFEHE IDFEI DFBGE GEKCG EGEFD FEFEF AHEGE KCICF EKEFD KAIDG CFCFE ICFEH DFBHE HAFCH DFEHD IBIAG CGEFE HEHEG EFCHE FEKCF AKEID FEIDF BGEGE FDFEI AGCFE HEGEK CICFE HEIAG CFEHB HDFBK DFEFC GAIDF BFAFA FBFAG BHAFB GBGCI AFDFE IDFCH DHEFE KCIAG AFBHD HEIAF BGCFC HBFEK EIAGC KCIAI AGCFE HEHBK CKDFE HDKCK DFEID FCIBG EKEGC FEGEH BIBHE IAIBH DFAFB FAGBI AGCFE HAFBH EHEFB GEFEH EGAHD FCHAI DFEKC HBFCF AHEFC GAIDK CHDIA FCKDK CHDHD FBFEH DHEFC GAHBF EKCKD FEKCF AKEGD FEFAF AFEKE KAHEF EFEHA FEKEI AFCGC KCICF EIAGC KCIAF BFAHA FBFAK EIDGC FEFAG CFEHE FEIAG CFBHE HBHDF CGBHD KCHAI AFCGE KCFAK EFCFA IAGCF EHAFC FCFAF DKAID FBFAF AFBFA GBIAG CFEHE HBKCK DFEHD KCKDF EIAGC FEKCK EHAFB FAFBH EIAHD KCIAF BFCFA GCFCH BFEKE IAFCF EHEIA KCFDG EFBHE GCIAG CFEHE IBHBH DFEHA KCKDK AFCGA IAGCF EKDKC HBFBI AKCGE FBHEI AHEKA HEIAF EHAFC ICFEH DKDFC HAHAI BFAFB HEHAK DFCID FBFAG BFCIB HDFEF AFEHA FBFEH EKCFA KEHEF EIAIA FBFAG BFCIB HDGCF EKCHD IAHEK CFAKE HAFBF AKEHE FCFAI AGCFE KDFCF AHCIB FEHEI AFCGA KCFAF EIDGA HDFCF AIAFB FEHDF DIBIA FDHDF EKBGC FAFEI CHEFE FEHAH EIBFA KEFEI AFEHD HDFEK EKCFA KEFEI CFEFA FDFEG AFCHD FEIAG CFEGE KCIBF AKDGC FCGAK CHBFC GEGEF CIEFB IAGCF EKCHA FEHDF BKDKC FAHBI BFDGE FBKDF BHEFD FEGBF BFAFA FBFAG BIAFC GBFEI AFDFC HDFEK EIAGC FEIAG CHDFE KCIAF CGAFA IBKDG EFEKC HDIDK CHDFB HEHDF BHEFB FAGBK CFAKE IAGCF EHBFE KCKDF EHBHD FCIAF EHEIA HEIDG CFBKD GCKCH DFEFB FAIAF EFAKE FEKEI AFCHB HDFEI CFEFA IAFBI AKCHD FEFEF AKDFC IBHDK CGBFB FAGBF CIBHD FEFAF EHAFB FEHEI AFCFD FEGEF BFEIC FEIAG CKCIA IAGCF EKAKD KCFAI DFBFA IDKCH DFBHE IBFAK CICFC FBKEK CFDGE FEIAF CHEIB HDICF BICFE FBIAI DFEHA IBHEI AGAFB GBGCI AFBIA FAFCI DFCFA FCIBH DFCID FAIAF EHDHA HEFDF EGAFC HDFEI AGCFE FAIBK DGEFE KCHDK CHDHE FEFAK CGEHE GBHDF CIDIA FCFCH BFCID FEHDG AIBGE FBGAF CIBHD GEFEK CKEFE HDHEI DFBGE GEFAF CIAKC KDIAF CGAIA GCFEF BHDFC IDFAI CFCGE FBIAF BFCFA IAGCF EFAFB IDFBG EGEHB HDFCI CFCGD FEIAG CFEHD FEHCI BFBHD FEKEK DFCFA GAHDF CFAIA KCIAF BFCFA FBIDF BGEGE KDFCF AICFB FAKDF EIAGC FEHAI AGCKC IAIAG CFEHD IBHEH EFBKC FAHEG CKCIC FEHEK CFDFC IAKCG BFEKE IAGCF EGEIB FAKCH DHBHD FCGBH DKCHA KCFAK EGDFB GEGEF EKEFC HDKCI AIAFE HAHBI AFEKE IAFCG DFBGE GEFCI BHDKC HEIAH DFCFA KCIBI AHEIA GCFEH DIBHE HEFBK CFAHE IDFBG EGEFA FEICF EHDFD FEKCF DGEFE IAFCH BHDFC ICFEI AGCKC IAIAG CFEKA KCHDF EFBFA FAFCK DFEFA IAKCF AKEFC IBHDH BFCGE FBIAF BKDFB KCFAH EKCFA KEGBF EFAFE HDKCG EHEID FBGEG EFDFE GAFCH DKDFE KEIAF CHEIA HDFBG DFEFD KCKDG DIAGC FEHDI BHEHE FBKCF AHEID FBGEG EFEHE KDKCG EKCIA FEFBF AFCHD KEFEH DIAFC FAFCI AGEFC FCGDI DFEKC GDKCF AKEFC FAKDF EIAGC FEKAG CKCIC FEKDF CHAHA FBIAI AFEKE IAGCF EHAHE FEGEI CFEHE IAGCF EHDFE IDFBG EGEFD FEFAF CIAIB HDFAF BFAGB FDKCK DGDIA GCFEI BFAKC ICFCF BKEKC FDGEF EIDKC HDIDF BGEGE GCKCI CFEIA FCFDF EGAFC IBGBG CIAIA FCFBI AHEKD FCFAK DGEIB HEFBF CFA diff --git a/2019/8b.given.plaintext b/2019/8b.given.plaintext new file mode 100644 index 0000000..a23954a --- /dev/null +++ b/2019/8b.given.plaintext @@ -0,0 +1 @@ +ifthedeathofoursoninkoreataughtmeanythingitisthatoureffortstocontainthesovietsbyproxywarsisdoomedasmyloathingofthesovietempirewasstokedbyhisdeaththeussrfeedsontheangerthatwestirupwitheachwarwefightinitspuppetstateswehavetriedtocontainitbutinowrealisethatwecanonlydefeatitthewaywefoughtfascismbytakingonitsmightinopenwarourpoliticianshaveshrunkfromtheconflictandtheyneedareasontoconfronttheevileventhethreatofnuclearmissilesbasedincubadidnotgivethemthemettletofightinsteadtheyhaveconvincedthemselvesthatthemaddoctrineofmutuallyassureddestructionwillprotectusandthatpeacecanbemaintainedundertheshelterofthenuclearumbrellatheydonotseemtoseethatthelongerwecowerinthisshadowthemorethetwosideswillinvestintheseawfulweaponsbeforelongitwillbeimpossibletofightatallwithoutthethreatoftotalannihilationandwhenthatdaycomeswewillallbeenslavedbywhoeverismoreruthlessloseandwewillbetheslavesthepriceofwinningmightbeworseatfirstihopedthatthespaceracewouldhelpusturningthemissilesfromweaponsofwartocarriersofpeaceandkennedyseemedtohavethatinmindwhenhesethisprogramtolandonthemoonbywinningthespaceracetheadministrationhopedtoestablishthesupremacyofthecapitalistsystemovercommunismcowingourenemiesandsettingourheartsandmindsontheconquestofanewfrontierbutbrezhnevseemsundeterredandevenbeforethelaunchofapolloxitheamericanpublicisbeginningtogetboredthethreatofnuclearwarisrisingandthepeaceprotestswhichareintendedtopreventitareencouragingourenemiestobelievethattheycanwinwarisunavoidabletosurviveitwemustfightitnowonourowntermsbeforethenucleararsenalsgrowtoopowerfulifourleaderswillnotactoftheirownvolitiontheniwillprovoketherequiredconfrontationiwillconvincethemthattherussianshavesabotagedthelunarprogramandkilledorattemptedtokillourastronautstherussianswillneverbeabletoprovethattheyareinnocentandourpoliticiansandgeneralswillbeforcedtostrikebacktherussianswillescalateinordertonotlookweakandoncetheyhavecommittedthemselvestherewillbenoturningbacktheunavoidablewarwillhavetobefoughttoitsconclusion diff --git a/2019/8b.plaintext b/2019/8b.plaintext new file mode 100644 index 0000000..1d7506a --- /dev/null +++ b/2019/8b.plaintext @@ -0,0 +1,25 @@ +if the death of our son in korea taught me anything it is that our efforts to contain the soviets by +proxy wars is doomed as my loathing of the soviet empire was stoked by his death the ussr feeds on +the anger that we stir up with each war we fight in its puppet states we have tried to contain it +but i now realise that we can only defeat it the way we fought fascism by taking on its might in +open war our politicians have shrunk from the conflict and they need a reason to confront the evil +even the threat of nuclear missiles based in cuba did not give them the mettle to fight instead they +have convinced themselves that the mad doctrine of mutually assured destruction will protect us and +that peace can be maintained under the shelter of the nuclear umbrella they do not seem to see that +the longer we cower in this shadow the more the two sides will invest in these awful weapons before +long it will be impossible to fight at all without the threat of total annihilation and when that +day comes we will all be enslaved by whoever is more ruthless lose and we will be the slaves the +price of winning might be worse at first i hoped that the space race would help us turning the +missiles from weapons of war to carriers of peace and kennedy seemed to have that in mind when he +set his program to landon the moon by winning the space race the administration hoped to establish +the supremacy of the capitalist system over communism cowing our enemies and setting our hearts and +minds on the conquest of a new frontier but brezhnev seems undeterred and even before the launch of +apollo xi the american public is beginning to get bored the threat of nuclear war is rising and the +peace protests which are intended to prevent it are encouraging our enemies to believe that they can +win war is unavoidable to survive it we must fight it now on our own terms before the nuclear +arsenals grow too powerful if our leaders will not act of their own volition then i will provoke the +required confrontation i will convince them that the russians have sabotaged the lunar program and +killed or attempted to kill our astronauts the russians will never be able to prove that they are +innocent and our politicians and generals will be forced to strike back the russians will escalate +in order to not look weak and once they have committed themselves there will be no turning back the +unavoidable war will have to be fought to its conclusion \ No newline at end of file diff --git a/cipher/vigenere.py b/cipher/vigenere.py index 362322d..f1cfe99 100644 --- a/cipher/vigenere.py +++ b/cipher/vigenere.py @@ -44,6 +44,16 @@ beaufort_variant_encipher=vigenere_decipher beaufort_variant_decipher=vigenere_encipher +def index_of_coincidence_scan(text, max_key_length=20): + """Finds the index of coincidence of the text, using different chunk sizes.""" + stext = sanitise(text) + iocs = {} + for i in range(1, max_key_length + 1): + splits = every_nth(stext, i) + mean_ioc = sum(index_of_coincidence(s) for s in splits) / i + iocs[i] = mean_ioc + return iocs + def vigenere_keyword_break_mp(message, wordlist=keywords, fitness=Pletters, chunksize=500): """Breaks a vigenere cipher using a dictionary and frequency analysis. -- 2.34.1