},
{
"cell_type": "code",
- "execution_count": 19,
+ "execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"open(plaintext_b_filename, 'w').write(lcat(tpack(segment(pb))))"
]
},
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def ioc_n(text):\n",
+ " counts = collections.Counter(text)\n",
+ " ltrs = set(text)\n",
+ " denom = len(text) * (len(text) - 1) / len(ltrs)\n",
+ " return (\n",
+ " sum(max(counts[l] * counts[l] - 1, 0) for l in ltrs)\n",
+ " /\n",
+ " denom\n",
+ " )"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 24,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "def ioc_scan_n(text, max_key_length=20):\n",
+ " \"\"\"Finds the index of coincidence of the text, using different chunk sizes.\"\"\"\n",
+ " iocs = {}\n",
+ " for i in range(1, max_key_length + 1):\n",
+ " splits = every_nth(text, i)\n",
+ " mean_ioc = sum(ioc_n(s) for s in splits) / i\n",
+ " iocs[i] = mean_ioc\n",
+ " return iocs"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 25,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "1.313469334794217"
+ ]
+ },
+ "execution_count": 25,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "ioc_n(scb)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 30,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "[(28, 1.029237612412878),\n",
+ " (56, 1.0323741101856603),\n",
+ " (14, 1.0886873582571082),\n",
+ " (42, 1.0923459702787721),\n",
+ " (1, 1.313469334794217),\n",
+ " (3, 1.3136724474583705),\n",
+ " (5, 1.3139446514243536),\n",
+ " (7, 1.3141262063060093),\n",
+ " (2, 1.3142346883552642),\n",
+ " (9, 1.3145299178890573),\n",
+ " (6, 1.3146522525866469),\n",
+ " (11, 1.314872121624653),\n",
+ " (10, 1.3153476328760576),\n",
+ " (17, 1.3156082632437882),\n",
+ " (19, 1.3157537470690668),\n",
+ " (15, 1.3158533079430723),\n",
+ " (18, 1.316306072127611),\n",
+ " (4, 1.3163246528314725),\n",
+ " (23, 1.3163277281569055),\n",
+ " (21, 1.3163473471920573),\n",
+ " (25, 1.316655118103681),\n",
+ " (8, 1.317040603398334),\n",
+ " (13, 1.3171605413165643),\n",
+ " (12, 1.3174113735517243),\n",
+ " (22, 1.317528984722072),\n",
+ " (33, 1.317594905094905),\n",
+ " (31, 1.317605231763728),\n",
+ " (27, 1.317688521561938),\n",
+ " (29, 1.3179986584465913),\n",
+ " (16, 1.3180422696887168),\n",
+ " (35, 1.318663902511151),\n",
+ " (38, 1.3186715456762172),\n",
+ " (37, 1.318782979178807),\n",
+ " (30, 1.3189277795375356),\n",
+ " (20, 1.319112577563282),\n",
+ " (41, 1.319293715271584),\n",
+ " (24, 1.319320503943391),\n",
+ " (34, 1.319372128500673),\n",
+ " (26, 1.3195881414435318),\n",
+ " (45, 1.319847955451339),\n",
+ " (51, 1.3198862305977204),\n",
+ " (43, 1.3202263262432186),\n",
+ " (32, 1.3204297829974077),\n",
+ " (46, 1.32083091670564),\n",
+ " (47, 1.320835215197834),\n",
+ " (49, 1.3208992566951445),\n",
+ " (36, 1.320917879222574),\n",
+ " (39, 1.3212746271240052),\n",
+ " (57, 1.3216014658027582),\n",
+ " (55, 1.3216742585772436),\n",
+ " (50, 1.321775386202746),\n",
+ " (40, 1.3220152407245682),\n",
+ " (48, 1.322371313582251),\n",
+ " (54, 1.3229352276740334),\n",
+ " (59, 1.322950472958544),\n",
+ " (44, 1.3231503579952266),\n",
+ " (53, 1.3232741220713358),\n",
+ " (58, 1.3236374480105653),\n",
+ " (52, 1.3262568828142518),\n",
+ " (60, 1.3264573374508233)]"
+ ]
+ },
+ "execution_count": 30,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "sorted(ioc_scan_n(scb, max_key_length=60).items(), key=lambda kv: kv[1])"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 33,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "image/png": "iVBORw0KGgoAAAANSUhEUgAAAa0AAAEmCAYAAADRIc8sAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAHZlJREFUeJzt3Xu8nVV95/HPzwS0Ihc1B8UEDI6hNfWKKaJWxOsEYqGiKLzU6QXMWAdFUUcY23DxClgvzKCIwmC9IXXUphIFbKXYIkiQWwIEIgQTLhIgXENIAmv+WL/NebI5J+cUdkgW+bxfr/M6e6+9znrWc1vf9Tx7ZydKKUiS1IInbewOSJI0XoaWJKkZhpYkqRmGliSpGYaWJKkZhpYkqRmGliSpGYaWJKkZhpYkqRmGliSpGRM31oInTZpUpk6durEWL0nahFx88cW3lVKGxqq30UJr6tSpzJ8/f2MtXpK0CYmIG8ZTz9uDkqRmGFqSpGYYWpKkZhhakqRmGFqSpGYYWpKkZhhakqRmGFqSpGYYWpKkZhhakqRmbLSvcZIkbXxTDz/zEWVLPjfrEeVLPjdrxPq98seLoSVtZOMdNDZ0+ViD0kjlm0rfB1W+OW6D1hhaY3giHqSeqJvWNpA0fr6nJUlqhqElSWqGoSVJaoahJUlqhqElSWqGoSVJaoahJUlqhqElSWqGoSVJaoahJUlqhqElSWqGoSVJaoahJUlqhqElSWqGoSVJaoahJUlqhqElSWrGmKEVEadGxK0RsWCU198VEZdHxBURcX5EvGTw3ZQkaXxXWqcBM9fz+vXAa0spLwI+CZw8gH5JkvQIE8eqUEo5LyKmruf18ztPLwCmPPZuSZL0SIN+T+sg4KejvRgRsyNifkTMX758+YAXLUl6ohtYaEXE66ih9fHR6pRSTi6lzCilzBgaGhrUoiVJm4kxbw+OR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2Qc9A/19keh3orofax1b+p7M72Pa64ETsz638+yQp2FHd/X3sO3B8mPkXfavZwahr3Z3EHAi6nvKV1OPSB7nxx6HnnSUE+uT3SWsRV1JrXtWOuRr/2SemBcBryh8zcvpV6y30kNrG6/3srwR5dLvn4Q9SS/JdftIerBflC2dx11dtVt51DqByjWUmdsvfJv5XLXZDs3ZfmfUm9LXEa9fdH7lNsHRtlP52Z57yPNC7P8fzF81bsm+7B3LveKbGcudZC6Ovuysq/v/2+UPi7rLLP3fsPe1FssqzvlF1FP4EsY/kj6ncCnc52+1Nm+a3Kf7t3Zl8v61vVihq/m786+bEkNmd4yr2f4GLqwb7mfyvIPderfR76nRT0W78n92D0W35HLfCDbuSz780zgX7Kfy6lv6o+2Tt3jfDXD/xyge9w+2FnXLakhsYB6NfWrrH9+p+93Mvzx/rdmPx6gTm5uHWPbd8/NxeTMnjoROzO3wQrgJVl+LnUSuyfDtwePz3qrqMfGAmrgvTjX5+58bSn1Y+Qn5/NV1HHgE51z/Y7s/8JO+Y8663o38Nks7233a6nHxFmddn6d63MuMC/L39e3vz8/whizurNtDs1tfg35KcoR6j/Y6efPOu3fQ30v9HnZj5WdbfDyLOtdrfaO16f3rdPDn4bd0D9+I4YkqRlN3h6UJG2eDC1JUjMMLUlSMwwtSVIzDC1JUjMMLUlSMwwtSVIzDC1JUjP+P/cYT/ivslEgAAAAAElFTkSuQmCC\n",
+ "text/plain": [
+ "<Figure size 432x288 with 1 Axes>"
+ ]
+ },
+ "metadata": {
+ "needs_background": "light"
+ },
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "ic = ioc_scan_n(scb, max_key_length=60)\n",
+ "plot_frequency_histogram(ic, sort_key=ic.get)"
+ ]
+ },
{
"cell_type": "code",
"execution_count": null,
--- /dev/null
+CVMMT,
+D VH MZVGGT NJMMT OJ WJOCZM TJP, WPO NJHZOCDIB CVN XJHZ PK VIY OCZ NDN VMZ OJJ WPNT OJ CZGK. D VH CJKDIB TJP XVI.
+AJGGJRDIB OCZ DIQVNDJI JA KJGVIY, RZ VMZ VGG JI YJPWGZ YPOT, OMVRGDIB OCMJPBC JGY ADGZN AJM VITOCDIB OCVO HDBCO WZ PNZAPG OJ JPM AMDZIYN DI ZPMJKZ. HT OZVH CVN WZZI VNFZY OJ GJJF VO DIOZGGDBZIXZ ADGZN XJIIZXOZY RDOC VDM OMVINKJMO VIY D RVN BDQZI OCZ CDIYZIWPMB YDNVNOZM OJ XCZXF JPO.
+OCZMZ DNI’O HPXC OJ BJ JI VN HJNO JA OCZ KVKZMN MZXJQZMZY AMJH OCZ RMZXFVBZ RZMZ WVYGT YVHVBZY. RZ YJ CVQZ V GVMBZ IPHWZM JA AMVBHZION JA OMVQZG YJXPHZION RCDXC D CVQZ NZIO OJ OCZ NOVOZ YZKVMOHZIO AJM DY XCZXFN, WPO OCVO RDGG OVFZ V RCDGZ, VIY DI OCZ HZVIODHZ, D CVQZ WZZI ZSVHDIDIB NJHZ JA OCZ HJMZ PIPNPVG DOZHN.
+OCZ HJNO DIOZMZNODIB JIZ DN V XCVMMZY ZIQZGJKZ XVMMTDIB V NRVNODFV VIY HVMFZY YDZ VGXCZHDNOZI. D OCDIF OCVO HDBCO WZ RJMOC DIQZNODBVODIB.
+OCZ XJIOZION RZMZ HDNNDIB, WPO DI OCZ NVHZ ZQDYZIXZ WVB D AJPIY V AMVBHZIO JA OJMI WGPZ KVKZM RDOC V IPHWZM DI OCZ WJOOJH XJMIZM. OCZMZ DN IJ YZNXMDKODJI RDOC DO, WPO D VH BPZNNDIB OCVO OCZT HPNO CVQZ WZZI AJPIY OJBZOCZM. RVOZM CVN YDNNJGQZY VIY JWNXPMZY OCZ IPHWZM NJ D XVI’O MZVY DO VIY D YJI’O MZXJBIDNZ OCZ AJMHVO. JI OCZ JOCZM CVIY, OCZ RVOZM HPNO CVQZ KMJOZXOZY DO AMJH OCZ CZVO JA OCZ AGVHZN VN OCZMZ VMZ IJ WPMI HVMFN VIY D RJIYZMZY DA TJPM S-MVT OZVH HDBCO WZ VWGZ OJ VNNDNO.
+CVQZ TJP NZZI VITOCDIB GDFZ DO WZAJMZ, JM CVQZ TJP CZVMY JA YDZ VGXCZHDNOZI? VITOCDIB TJP CVQZ RJPGY WZ BMZVO. OCVIFN
+KCDG
--- /dev/null
+HARRY,
+I AM REALLY SORRY TO BOTHER YOU, BUT SOMETHING HAS COME UP AND THE SIS ARE TOO BUSY TO HELP. I AM HOPING YOU CAN.
+FOLLOWING THE INVASION OF POLAND, WE ARE ALL ON DOUBLE DUTY, TRAWLING THROUGH OLD FILES FOR ANYTHING THAT MIGHT BE USEFUL TO OUR FRIENDS IN EUROPE. MY TEAM HAS BEEN ASKED TO LOOK AT INTELLIGENCE FILES CONNECTED WITH AIR TRANSPORT AND I WAS GIVEN THE HINDENBURG DISASTER TO CHECK OUT.
+THERE ISN'T MUCH TO GO ON AS MOST OF THE PAPERS RECOVERED FROM THE WRECKAGE WERE BADLY DAMAGED. WE DO HAVE A LARGE NUMBER OF FRAGMENTS OF TRAVEL DOCUMENTS WHICH I HAVE SENT TO THE STATE DEPARTMENT FOR ID CHECKS, BUT THAT WILL TAKE A WHILE, AND IN THE MEANTIME, I HAVE BEEN EXAMINING SOME OF THE MORE UNUSUAL ITEMS.
+THE MOST INTERESTING ONE IS A CHARRED ENVELOPE CARRYING A SWASTIKA AND MARKED DIE ALCHEMISTEN. I THINK THAT MIGHT BE WORTH INVESTIGATING.
+THE CONTENTS WERE MISSING, BUT IN THE SAME EVIDENCE BAG I FOUND A FRAGMENT OF TORN BLUE PAPER WITH A NUMBER IN THE BOTTOM CORNER. THERE IS NO DESCRIPTION WITH IT, BUT I AM GUESSING THAT THEY MUST HAVE BEEN FOUND TOGETHER. WATER HAS DISSOLVED AND OBSCURED THE NUMBER SO I CAN'T READ IT AND I DON'T RECOGNISE THE FORMAT. ON THE OTHER HAND, THE WATER MUST HAVE PROTECTED IT FROM THE HEAT OF THE FLAMES AS THERE ARE NO BURN MARKS AND I WONDERED IF YOUR X-RAY TEAM MIGHT BE ABLE TO ASSIST.
+HAVE YOU SEEN ANYTHING LIKE IT BEFORE, OR HAVE YOU HEARD OF DIE ALCHEMISTEN? ANYTHING YOU HAVE WOULD BE GREAT. THANKS
+PHIL
--- /dev/null
+XPQT, QB QA OWWL BW PMIZ NZWU GWC. BPQVOA IZM PMKBQK PMZM BWW, JCB QB QA UIQVTG JCZMICKZIKG IA EM BZG BW UISM ACZM ITT BPM JWAA NQMTL IOMVBA PIDM AMKCZM KPIVVMTA WN KWUUCVQKIBQWV IVL ZWCBMA WCB WN BZWCJTM QN BPMG VMML BPMU. QB QA MAAMVBQIT EWZS, JCB Q PIDM JMMV QBKPQVO BW OMB WCB BPMZM EQBP BPMU IVL GWCZ TMBBMZ KIUM IB BPM ZQOPB BQUM.
+Q PIDMV’B PMIZL WN LQM ITKPMUQABMV JMNWZM, JCB QB LWMA ZMUQVL UM WN AWUMBPQVO BPIB Q KIV’B YCQBM XTIKM. Q EQTT OMB JIKS BW GWC QN Q ZMUMUJMZ. BPM VCUJMZ QA ATQOPBTG MIAQMZ. BPQA TWWSA TQSM BPM JWBBWU ZQOPB KWZVMZ WN I JTCMXZQVB IVL Q IAACUM BPM VCUJMZ QA ZMTIBML BW BPM LMAQOV. BPM F-ZIG BMIU BWWS I AVIX EPQKP QVKZMIAML BPM KWVBZIAB IVL Q BPQVS Q KIV UISM WCB BPM TMBBMZA OJ IB BPM ABIZB, EPQKP QA ACOOMABQDM. BPM VMFB BEW LQOQBA IZM VWB KTMIZ, JCB BPMG KWCTL JM MQOPB-BPZMM WZ MQOPB-NQDM. Q PIDM AMVB I ZMYCMAB BW BPM CS UQTQBIZG IBBIKPM BW AMM QN PM ZMKWOVQAMA BPM NWZUIB.
+Q EQTT JM QV BWCKP QV AMDMV LIGA.
+PIZZG
--- /dev/null
+PHIL, IT IS GOOD TO HEAR FROM YOU. THINGS ARE HECTIC HERE TOO, BUT IT IS MAINLY BUREAUCRACY AS WE TRY TO MAKE SURE ALL THE BOSS FIELD AGENTS HAVE SECURE CHANNELS OF COMMUNICATION AND ROUTES OUT OF TROUBLE IF THEY NEED THEM. IT IS ESSENTIAL WORK, BUT I HAVE BEEN ITCHING TO GET OUT THERE WITH THEM AND YOUR LETTER CAME AT THE RIGHT TIME.
+I HAVEN'T HEARD OF DIE ALCHEMISTEN BEFORE, BUT IT DOES REMIND ME OF SOMETHING THAT I CAN'T QUITE PLACE. I WILL GET BACK TO YOU IF I REMEMBER. THE NUMBER IS SLIGHTLY EASIER. THIS LOOKS LIKE THE BOTTOM RIGHT CORNER OF A BLUEPRINT AND I ASSUME THE NUMBER IS RELATED TO THE DESIGN. THE X-RAY TEAM TOOK A SNAP WHICH INCREASED THE CONTRAST AND I THINK I CAN MAKE OUT THE LETTERS GB AT THE START, WHICH IS SUGGESTIVE. THE NEXT TWO DIGITS ARE NOT CLEAR, BUT THEY COULD BE EIGHT-THREE OR EIGHT-FIVE. I HAVE SENT A REQUEST TO THE UK MILITARY ATTACHE TO SEE IF HE RECOGNISES THE FORMAT.
+I WILL BE IN TOUCH IN SEVEN DAYS.
+HARRY
--- /dev/null
+{
+ "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 *"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "challenge_number = 1\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": 5,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "ca = open(ciphertext_a_filename).read()\n",
+ "cb = open(ciphertext_b_filename).read()\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "21 \n",
+ "\n",
+ "HARRY,\n",
+ "I AM REALLY SORRY TO BOTHER YOU, BUT SOMETHING HAS COME UP AND THE SIS ARE TOO BUSY TO HELP. I AM HOPING YOU CAN.\n",
+ "FOLLOWING THE INVASION OF POLAND, WE ARE ALL ON DOUBLE DUTY, TRAWLING THROUGH OLD FILES FOR ANYTHING THAT MIGHT BE USEFUL TO OUR FRIENDS IN EUROPE. MY TEAM HAS BEEN ASKED TO LOOK AT INTELLIGENCE FILES CONNECTED WITH AIR TRANSPORT AND I WAS GIVEN THE HINDENBURG DISASTER TO CHECK OUT.\n",
+ "THERE ISN'T MUCH TO GO ON AS MOST OF THE PAPERS RECOVERED FROM THE WRECKAGE WERE BADLY DAMAGED. WE DO HAVE A LARGE NUMBER OF FRAGMENTS OF TRAVEL DOCUMENTS WHICH I HAVE SENT TO THE STATE DEPARTMENT FOR ID CHECKS, BUT THAT WILL TAKE A WHILE, AND IN THE MEANTIME, I HAVE BEEN EXAMINING SOME OF THE MORE UNUSUAL ITEMS.\n",
+ "THE MOST INTERESTING ONE IS A CHARRED ENVELOPE CARRYING A SWASTIKA AND MARKED DIE ALCHEMISTEN. I THINK THAT MIGHT BE WORTH INVESTIGATING.\n",
+ "THE CONTENTS WERE MISSING, BUT IN THE SAME EVIDENCE BAG I FOUND A FRAGMENT OF TORN BLUE PAPER WITH A NUMBER IN THE BOTTOM CORNER. THERE IS NO DESCRIPTION WITH IT, BUT I AM GUESSING THAT THEY MUST HAVE BEEN FOUND TOGETHER. WATER HAS DISSOLVED AND OBSCURED THE NUMBER SO I CAN'T READ IT AND I DON'T RECOGNISE THE FORMAT. ON THE OTHER HAND, THE WATER MUST HAVE PROTECTED IT FROM THE HEAT OF THE FLAMES AS THERE ARE NO BURN MARKS AND I WONDERED IF YOUR X-RAY TEAM MIGHT BE ABLE TO ASSIST.\n",
+ "HAVE YOU SEEN ANYTHING LIKE IT BEFORE, OR HAVE YOU HEARD OF DIE ALCHEMISTEN? ANYTHING YOU HAVE WOULD BE GREAT. THANKS\n",
+ "PHIL\n",
+ "\n"
+ ]
+ }
+ ],
+ "source": [
+ "k_a, score_a = caesar_break(ca)\n",
+ "print(k_a, '\\n')\n",
+ "pa = caesar_decipher(ca, k_a)\n",
+ "print(pa)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 10,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "1466"
+ ]
+ },
+ "execution_count": 10,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "open(plaintext_a_filename, 'w').write(pa)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "8 \n",
+ "\n",
+ "PHIL, IT IS GOOD TO HEAR FROM YOU. THINGS ARE HECTIC HERE TOO, BUT IT IS MAINLY BUREAUCRACY AS WE TRY TO MAKE SURE ALL THE BOSS FIELD AGENTS HAVE SECURE CHANNELS OF COMMUNICATION AND ROUTES OUT OF TROUBLE IF THEY NEED THEM. IT IS ESSENTIAL WORK, BUT I HAVE BEEN ITCHING TO GET OUT THERE WITH THEM AND YOUR LETTER CAME AT THE RIGHT TIME.\n",
+ "I HAVEN'T HEARD OF DIE ALCHEMISTEN BEFORE, BUT IT DOES REMIND ME OF SOMETHING THAT I CAN'T QUITE PLACE. I WILL GET BACK TO YOU IF I REMEMBER. THE NUMBER IS SLIGHTLY EASIER. THIS LOOKS LIKE THE BOTTOM RIGHT CORNER OF A BLUEPRINT AND I ASSUME THE NUMBER IS RELATED TO THE DESIGN. THE X-RAY TEAM TOOK A SNAP WHICH INCREASED THE CONTRAST AND I THINK I CAN MAKE OUT THE LETTERS GB AT THE START, WHICH IS SUGGESTIVE. THE NEXT TWO DIGITS ARE NOT CLEAR, BUT THEY COULD BE EIGHT-THREE OR EIGHT-FIVE. I HAVE SENT A REQUEST TO THE UK MILITARY ATTACHE TO SEE IF HE RECOGNISES THE FORMAT.\n",
+ "I WILL BE IN TOUCH IN SEVEN DAYS.\n",
+ "HARRY\n",
+ "\n"
+ ]
+ }
+ ],
+ "source": [
+ "k_b, score_b = caesar_break(cb)\n",
+ "print(k_b, '\\n')\n",
+ "pb = caesar_decipher(cb, k_b)\n",
+ "print(pb)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "953"
+ ]
+ },
+ "execution_count": 14,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "open(plaintext_b_filename, 'w').write(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.7.4"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}
--- /dev/null
+{
+ "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": 8,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "from cipher.caesar import *\n",
+ "from cipher.affine import *\n",
+ "\n",
+ "from support.text_prettify import *\n",
+ "from support.utilities import *\n",
+ "from support.plot_frequency_histogram import *"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "challenge_number = 2\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": 9,
+ "metadata": {},
+ "outputs": [],
+ "source": [
+ "ca = open(ciphertext_a_filename).read()\n",
+ "cb = open(ciphertext_b_filename).read()\n",
+ "\n",
+ "sca = sanitise(ca)\n",
+ "pca = letters(ca)\n",
+ "pta = depunctuate(ca)\n",
+ "\n",
+ "scb = sanitise(cb)\n",
+ "pcb = letters(cb)\n",
+ "ptb = depunctuate(cb)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 14,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "(3, 6, True) \n",
+ "\n",
+ "PHIL I HEARD BACK FROM THE BRITISH MILITARY ATTACHE STOP HE SAID THAT THE NUMBER LOOKS LIKE THE FORMAT USED BY THE PATENT OFFICE STOP HE SUGGESTED THAT THE DOCUMENT MIGHT HAVE BEEN A DESIGN DRAWING FOR AN INVENTION STOP ONE OF OUR FIELD AGENTS TRIED TO FIND OUT WHICH ONE BUT THE NUMBERS LOOKED WRONG STOP PATENT NUMBERS STARTING GB EIGHT HAVE NOT BEEN ISSUED YET STOP THE AGENT HAD NOT SEEN THE PHOTO YOU SENT BUT SHE SHOWED INITIATIVE AND TRIED SOME OTHER NUMBERS STOP GB-SIX-THREE-ZERO-SEVEN-TWO-SIX-A WAS THE MOST PROMISING STOP CHECKED WITH OUR EXPERTS AND THEY WERE CONFUSED STOP ACCORDING TO COCKCROFT THE INVENTION IS IMPRACTICAL STOP SOMEONE POINTED OUT THAT IT FITS WITH THE NAME DIE ALCHEMISTEN STOP SEE ATTACHED STOP WILL INVESTIGATE FURTHER STOP NEXT COMMUNICATION IN SEVEN DAYS STOP\n",
+ "\n"
+ ]
+ }
+ ],
+ "source": [
+ "(ma, ca, za), score_a = affine_break(sca)\n",
+ "print((ma, ca, za), '\\n')\n",
+ "pa = repunctuate(affine_decipher(sca, ma, ca, za), pta)\n",
+ "print(pa)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 13,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "797"
+ ]
+ },
+ "execution_count": 13,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "open(plaintext_a_filename, 'w').write(pa)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 12,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "(3, 6, True) \n",
+ "\n",
+ "PHIL I HEARD BACK FROM THE BRITISH MILITARY ATTACHE STOP HE SAID THAT THE NUMBER LOOKS LIKE THE FORMAT USED BY THE PATENT OFFICE STOP HE SUGGESTED THAT THE DOCUMENT MIGHT HAVE BEEN A DESIGN DRAWING FOR AN INVENTION STOP ONE OF OUR FIELD AGENTS TRIED TO FIND OUT WHICH ONE BUT THE NUMBERS LOOKED WRONG STOP PATENT NUMBERS STARTING GB EIGHT HAVE NOT BEEN ISSUED YET STOP THE AGENT HAD NOT SEEN THE PHOTO YOU SENT BUT SHE SHOWED INITIATIVE AND TRIED SOME OTHER NUMBERS STOP GB-SIX-THREE-ZERO-SEVEN-TWO-SIX-A WAS THE MOST PROMISING STOP CHECKED WITH OUR EXPERTS AND THEY WERE CONFUSED STOP ACCORDING TO COCKCROFT THE INVENTION IS IMPRACTICAL STOP SOMEONE POINTED OUT THAT IT FITS WITH THE NAME DIE ALCHEMISTEN STOP SEE ATTACHED STOP WILL INVESTIGATE FURTHER STOP NEXT COMMUNICATION IN SEVEN DAYS STOP\n",
+ "\n"
+ ]
+ }
+ ],
+ "source": [
+ "(mb, cb, zb), score_a = affine_break(scb)\n",
+ "print((mb, cb, z) '\\n')\n",
+ "pa = repunctuate(affine_decipher(sca, ma, ca, za), pta)\n",
+ "print(pa)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 9,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "21 \n",
+ "\n",
+ "HARRY,\n",
+ "I AM REALLY SORRY TO BOTHER YOU, BUT SOMETHING HAS COME UP AND THE SIS ARE TOO BUSY TO HELP. I AM HOPING YOU CAN.\n",
+ "FOLLOWING THE INVASION OF POLAND, WE ARE ALL ON DOUBLE DUTY, TRAWLING THROUGH OLD FILES FOR ANYTHING THAT MIGHT BE USEFUL TO OUR FRIENDS IN EUROPE. MY TEAM HAS BEEN ASKED TO LOOK AT INTELLIGENCE FILES CONNECTED WITH AIR TRANSPORT AND I WAS GIVEN THE HINDENBURG DISASTER TO CHECK OUT.\n",
+ "THERE ISN'T MUCH TO GO ON AS MOST OF THE PAPERS RECOVERED FROM THE WRECKAGE WERE BADLY DAMAGED. WE DO HAVE A LARGE NUMBER OF FRAGMENTS OF TRAVEL DOCUMENTS WHICH I HAVE SENT TO THE STATE DEPARTMENT FOR ID CHECKS, BUT THAT WILL TAKE A WHILE, AND IN THE MEANTIME, I HAVE BEEN EXAMINING SOME OF THE MORE UNUSUAL ITEMS.\n",
+ "THE MOST INTERESTING ONE IS A CHARRED ENVELOPE CARRYING A SWASTIKA AND MARKED DIE ALCHEMISTEN. I THINK THAT MIGHT BE WORTH INVESTIGATING.\n",
+ "THE CONTENTS WERE MISSING, BUT IN THE SAME EVIDENCE BAG I FOUND A FRAGMENT OF TORN BLUE PAPER WITH A NUMBER IN THE BOTTOM CORNER. THERE IS NO DESCRIPTION WITH IT, BUT I AM GUESSING THAT THEY MUST HAVE BEEN FOUND TOGETHER. WATER HAS DISSOLVED AND OBSCURED THE NUMBER SO I CAN'T READ IT AND I DON'T RECOGNISE THE FORMAT. ON THE OTHER HAND, THE WATER MUST HAVE PROTECTED IT FROM THE HEAT OF THE FLAMES AS THERE ARE NO BURN MARKS AND I WONDERED IF YOUR X-RAY TEAM MIGHT BE ABLE TO ASSIST.\n",
+ "HAVE YOU SEEN ANYTHING LIKE IT BEFORE, OR HAVE YOU HEARD OF DIE ALCHEMISTEN? ANYTHING YOU HAVE WOULD BE GREAT. THANKS\n",
+ "PHIL\n",
+ "\n"
+ ]
+ }
+ ],
+ "source": [
+ "k_a, score_b = caesar_break(ca)\n",
+ "print(k_a, '\\n')\n",
+ "pa = caesar_decipher(ca, k_a)\n",
+ "print(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.7.4"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 4
+}
--- /dev/null
+BDGP G DUIHR LIOM XHYS NDU LHGNGKD SGPGNIHC INNIODU KNYB DU KIGR NDIN NDU VQSLUH PYYMK PGMU NDU XYHSIN QKUR LC NDU BINUVN YXXGOU KNYB DU KQAAUKNUR NDIN NDU RYOQSUVN SGADN DITU LUUV I RUKGAV RHIWGVA XYH IV GVTUVNGYV KNYB YVU YX YQH XGUPR IAUVNK NHGUR NY XGVR YQN WDGOD YVU LQN NDU VQSLUHK PYYMUR WHYVA KNYB BINUVN VQSLUHK KNIHNGVA AL UGADN DITU VYN LUUV GKKQUR CUN KNYB NDU IAUVN DIR VYN KUUV NDU BDYNY CYQ KUVN LQN KDU KDYWUR GVGNGINGTU IVR NHGUR KYSU YNDUH VQSLUHK KNYB AL-KGZ-NDHUU-FUHY-KUTUV-NWY-KGZ-I WIK NDU SYKN BHYSGKGVA KNYB ODUOMUR WGND YQH UZBUHNK IVR NDUC WUHU OYVXQKUR KNYB IOOYHRGVA NY OYOMOHYXN NDU GVTUVNGYV GK GSBHIONGOIP KNYB KYSUYVU BYGVNUR YQN NDIN GN XGNK WGND NDU VISU RGU IPODUSGKNUV KNYB KUU INNIODUR KNYB WGPP GVTUKNGAINU XQHNDUH KNYB VUZN OYSSQVGOINGYV GV KUTUV RICK KNYB
--- /dev/null
+PHIL I HEARD BACK FROM THE BRITISH MILITARY ATTACHE STOP HE SAID THAT THE NUMBER LOOKS LIKE THE FORMAT USED BY THE PATENT OFFICE STOP HE SUGGESTED THAT THE DOCUMENT MIGHT HAVE BEEN A DESIGN DRAWING FOR AN INVENTION STOP ONE OF OUR FIELD AGENTS TRIED TO FIND OUT WHICH ONE BUT THE NUMBERS LOOKED WRONG STOP PATENT NUMBERS STARTING GB EIGHT HAVE NOT BEEN ISSUED YET STOP THE AGENT HAD NOT SEEN THE PHOTO YOU SENT BUT SHE SHOWED INITIATIVE AND TRIED SOME OTHER NUMBERS STOP GB-SIX-THREE-ZERO-SEVEN-TWO-SIX-A WAS THE MOST PROMISING STOP CHECKED WITH OUR EXPERTS AND THEY WERE CONFUSED STOP ACCORDING TO COCKCROFT THE INVENTION IS IMPRACTICAL STOP SOMEONE POINTED OUT THAT IT FITS WITH THE NAME DIE ALCHEMISTEN STOP SEE ATTACHED STOP WILL INVESTIGATE FURTHER STOP NEXT COMMUNICATION IN SEVEN DAYS STOP
--- /dev/null
+GLKKF, J RGXRPXU BTQ QGX ELQXYQ FBT LNPXU VX LOBTQ. J QGJYP JQ VJDGQ OX KXSLQXU QB L SXRQTKX RBRPRKBAQ UXSJWXKXU LQ QGX JYNQJQTQX BA XSXRQKJRLS XYDJYXXKN BY LEKJS QZXYQF QGJKU YJYXQXXY QGJKQF NJC. QGX QBEJR ZLN "QGX QKLYNVTQLQJBY BA VLQQXK OF GJDG XYXKDF ELKQJRSXN LYU KLUJLQJBYN". DJWXY QGX SLOXS BY QGX GJYUXYOTKD XYWXSBEX J QGJYP QGX ABSSBZJYD XCQKLRQ JN ELKQJRTSLKSF JYQXKXNQJYD: "JY QGX RLNX BA YTRSXLK QKLYNVTQLQJBYN, JQ NXXVN QGLQ QGX SBNN BA VLNN JN EKXRJNXSF XHTLS QB QGX JYRKXLNX JY QGX PJYXQJR XYXKDF QGLQ GLN QLPXY ESLRX. QGJN DJWXN L NQKJPJYD EKBBA BA QGX VBUXKY EGFNJRLS SLZ QGLQ VLNN LYU XYXKDF LKX XHTJWLSXYQ. JY YJYXQXXY QGJKQF QZB RGLUZJRP UJNRBWXKXU QGX YXTQKBY, L YXZ QFEX BA LQBVJR ELKQJRSX ZGJRG GLN YB XSXRQKJR RGLKDX. JQ UBXN YBQ QGXKXABKX JYQXKLRQ ZJQG BQGXK XSXRQKBYN LYU EKBUTRXN YB JBYJNLQJBY ZGXY ELNNJYD QGKBTDG L DLN. JQ JN BA BTQNQLYUJYD JVEBKQLYRX OXRLTNX BA JQN EBZXK QB EKBUTRX QKLYNVTQLQJBYN. QGXKX JN SJQQSX GBEX QGLQ QGJN EKBRXNN RLY OX TNXU BY LY XYDJYXXKJYD NRLSX QB RBYWXKQ VLNN JYQB XYXKDF. NB ALK, BTK SLOBKLQBKF XCEXKJVXYQN EKBUTRX QGX RBYWXKNX KXNTSQ. QGXBKF JYUJRLQXN QGLQ LQ QXVEXKLQTKXN XHTLS QB QGBNX BA QGX JYQXKJBK BA QGX NTY BK NQLKN, JQ VJDGQ OX EBNNJOSX QB RBYWXKQ QGX JYXCEXYNJWX NJVESX XSXVXYQN QB QGX VBKX WLSTLOSX GXLWJXK RBVOJYLQJBYN, OTQ EKLRQJRLSSF, QGXKX JN YB VXQGBU BA EKBUTRJYD QGX XAAXRQN ABKVXKSF LQQKJOTQXU QB QGX 'EGJSBNBEGXK'N NQBYX'."
--- /dev/null
+HARRY, I CHECKED OUT THE PATENT YOU ASKED ME ABOUT. I THINK IT MIGHT BE RELATED TO A LECTURE COCKCROFT DELIVERED AT THE INSTITUTE OF ELECTRICAL ENGINEERS ON APRIL TWENTY THIRD NINETEEN THIRTY SIX. THE TOPIC WAS "THE TRANSMUTATION OF MATTER BY HIGH ENERGY PARTICLES AND RADIATIONS". GIVEN THE LABEL ON THE HINDENBURG ENVELOPE I THINK THE FOLLOWING EXTRACT IS PARTICULARLY INTERESTING: "IN THE CASE OF NUCLEAR TRANSMUTATIONS, IT SEEMS THAT THE LOSS OF MASS IS PRECISELY EQUAL TO THE INCREASE IN THE KINETIC ENERGY THAT HAS TAKEN PLACE. THIS GIVES A STRIKING PROOF OF THE MODERN PHYSICAL LAW THAT MASS AND ENERGY ARE EQUIVALENT. IN NINETEEN THIRTY TWO CHADWICK DISCOVERED THE NEUTRON, A NEW TYPE OF ATOMIC PARTICLE WHICH HAS NO ELECTRIC CHARGE. IT DOES NOT THEREFORE INTERACT WITH OTHER ELECTRONS AND PRODUCES NO IONISATION WHEN PASSING THROUGH A GAS. IT IS OF OUTSTANDING IMPORTANCE BECAUSE OF ITS POWER TO PRODUCE TRANSMUTATIONS. THERE IS LITTLE HOPE THAT THIS PROCESS CAN BE USED ON AN ENGINEERING SCALE TO CONVERT MASS INTO ENERGY. SO FAR, OUR LABORATORY EXPERIMENTS PRODUCE THE CONVERSE RESULT. THEORY INDICATES THAT AT TEMPERATURES EQUAL TO THOSE OF THE INTERIOR OF THE SUN OR STARS, IT MIGHT BE POSSIBLE TO CONVERT THE INEXPENSIVE SIMPLE ELEMENTS TO THE MORE VALUABLE HEAVIER COMBINATIONS, BUT PRACTICALLY, THERE IS NO METHOD OF PRODUCING THE EFFECTS FORMERLY ATTRIBUTED TO THE 'PHILOSOPHER'S STONE'."