Done challenge 9
[cipher-challenge.git] / 2021 / 2021-challenge8.ipynb
1 {
2 "cells": [
3 {
4 "cell_type": "code",
5 "execution_count": 31,
6 "id": "5c19999b",
7 "metadata": {
8 "Collapsed": "false"
9 },
10 "outputs": [],
11 "source": [
12 "from szyfrow.caesar import *\n",
13 "from szyfrow.affine import *\n",
14 "from szyfrow.keyword_cipher import *\n",
15 "from szyfrow.column_transposition import *\n",
16 "from szyfrow.vigenere import *\n",
17 "from szyfrow.polybius import *\n",
18 "from szyfrow.railfence import *\n",
19 "from szyfrow.support.text_prettify import *\n",
20 "\n",
21 "import numpy as np\n",
22 "import pandas as pd\n",
23 "import matplotlib.pyplot as plt\n",
24 "\n",
25 "import collections\n",
26 "%matplotlib inline"
27 ]
28 },
29 {
30 "cell_type": "code",
31 "execution_count": 2,
32 "id": "d9dd1b5e",
33 "metadata": {
34 "Collapsed": "false"
35 },
36 "outputs": [],
37 "source": [
38 "challenge_number = 8\n",
39 "plaintext_a_filename = f'plaintext.{challenge_number}a.txt'\n",
40 "plaintext_b_filename = f'plaintext.{challenge_number}b.txt'\n",
41 "ciphertext_a_filename = f'ciphertext.{challenge_number}a.txt'\n",
42 "ciphertext_b_filename = f'ciphertext.{challenge_number}b.txt'"
43 ]
44 },
45 {
46 "cell_type": "code",
47 "execution_count": 3,
48 "id": "0f1f792a",
49 "metadata": {
50 "Collapsed": "false"
51 },
52 "outputs": [],
53 "source": [
54 "ca = open(ciphertext_a_filename).read()\n",
55 "ncb = open(ciphertext_b_filename).read()\n",
56 "\n",
57 "numtrans = ''.maketrans('12345', 'abcde')\n",
58 "cb = ncb.translate(numtrans)\n",
59 "\n",
60 "sca = sanitise(ca)\n",
61 "rsca = cat(reversed(sca))\n",
62 "scb = sanitise(cb)\n",
63 "rscb = cat(reversed(scb))"
64 ]
65 },
66 {
67 "cell_type": "code",
68 "execution_count": 4,
69 "id": "b8d5f9ec-27f1-498b-8e64-c5eb2424e581",
70 "metadata": {},
71 "outputs": [
72 {
73 "data": {
74 "text/plain": [
75 "Counter({'d': 45,\n",
76 " 'e': 105,\n",
77 " 'c': 90,\n",
78 " 'r': 120,\n",
79 " 'o': 43,\n",
80 " 'a': 76,\n",
81 " 'k': 113,\n",
82 " 'n': 44,\n",
83 " 'y': 110,\n",
84 " 'z': 91,\n",
85 " 'j': 60,\n",
86 " 'l': 111,\n",
87 " 'p': 91,\n",
88 " 'w': 45,\n",
89 " 'f': 110,\n",
90 " 't': 93,\n",
91 " 'v': 118,\n",
92 " 'i': 87,\n",
93 " 'u': 61,\n",
94 " 'm': 58,\n",
95 " 'g': 43,\n",
96 " 's': 51,\n",
97 " 'x': 16,\n",
98 " 'b': 31,\n",
99 " 'h': 48,\n",
100 " 'q': 17})"
101 ]
102 },
103 "execution_count": 4,
104 "metadata": {},
105 "output_type": "execute_result"
106 }
107 ],
108 "source": [
109 "sca_counts = collections.Counter(sca)\n",
110 "sca_counts"
111 ]
112 },
113 {
114 "cell_type": "code",
115 "execution_count": 5,
116 "id": "b5cabba1-ac75-46ea-ac05-8699cc88d986",
117 "metadata": {
118 "tags": []
119 },
120 "outputs": [
121 {
122 "data": {
123 "text/plain": [
124 "<AxesSubplot:>"
125 ]
126 },
127 "execution_count": 5,
128 "metadata": {},
129 "output_type": "execute_result"
130 },
131 {
132 "data": {
133 "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAASjUlEQVR4nO3de7SldV3H8fdHMFDwMsQBJy4OuiYVzZZ6vBUVKzIpL1CJQWXjpWapaGalDN0oVxSt7lloE15GRZFQg7LEacqFVqIDqFwGA0VxdGSmvLFKhbFvf+xnYnvct7P3OTNnfvN+rbXXPs+zf7/n+Z7n7PPZv/3bez87VYUkqS332tcFSJKWnuEuSQ0y3CWpQ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auj/8x5VVUk+39W2G1gFXJZkc1UNemadqtoNvDjJc+lNy60at59+KzHctyd5IPC3wOYkX2TEqQv6AuHewM8mub1bfjC9UclAVfWmJFuBH6T3j/bjtWAubYA3Ax9K8q5uHz9G72npKH8OvAs4Ksn59KYcfn1Mn2m8ld5T7Mu75WcAb0tyGAuOQ98xOxh4XpJP0gu3sXPOy+zpe3l/z6P3zPDe3POAW8CocD8JeG6S25j8mL2B3gPUu7rl04HXjantidxzf4ZeeG/b87cbsL9p7ptU1afHtVng2cCpwB9W1ZeSrAZeMWTbX6b3us9Zg24fZcED/UHAHDD0dY0kLwJ+smt3GfDzE/w/fwx4HPCors4vJfn3qvrqiD4fpjc193jg24G/SvKsqnrWiNp+AVhH78RfFwGvqKq7k9wLuAUYFO6v3fNDVb2xOx5nj/l9vnm/3VOAFSnJD9B7OvKe6p06eFCbB4/axhR33nE1PZZ7Xhi7qqqum6DPw4FT6AXBlqratpQ19e3ncfTCJ/SmHAbO1e/tY7ZSJbm+qr5rkX0GHrtxx6y73+z524y930zzN5rmvrlSLfj9dwN3dCPZYe0vAC6pIW8eGLOvw+k90P8KvTc7HDKi7fzC/6skz6mqoa+HJHkV8Lohf7NHLFserORwl5ZTkr8G/mSCEZ4a1L2L5fvojd4/zT3vnPnnfVrYEjHcdcBKsg14KL0X+FbCtJT2oiSvoBfo14x6VrC/Mtx1wJp2ikXaHxjuktSgFfchJknS7Ax3SWqQ4S5JDTLcJalBhrskNej/AFp8npMkoqciAAAAAElFTkSuQmCC\n",
134 "text/plain": [
135 "<Figure size 432x288 with 1 Axes>"
136 ]
137 },
138 "metadata": {
139 "needs_background": "light"
140 },
141 "output_type": "display_data"
142 }
143 ],
144 "source": [
145 "pd.Series(sca_counts).sort_index().plot.bar()"
146 ]
147 },
148 {
149 "cell_type": "code",
150 "execution_count": 7,
151 "id": "583312cf-a973-4671-9ba8-85fe10cb9e00",
152 "metadata": {},
153 "outputs": [
154 {
155 "data": {
156 "text/plain": [
157 "('harry', -6318.403758350804)"
158 ]
159 },
160 "execution_count": 7,
161 "metadata": {},
162 "output_type": "execute_result"
163 }
164 ],
165 "source": [
166 "key_a, score_a = vigenere_frequency_break(sca, fitness=Ptrigrams)\n",
167 "key_a, score_a"
168 ]
169 },
170 {
171 "cell_type": "code",
172 "execution_count": 9,
173 "id": "b371ff9c-dbe0-43d9-95a4-1b6766090a6e",
174 "metadata": {},
175 "outputs": [
176 {
177 "data": {
178 "text/plain": [
179 "'wellthatwasasurpriseifoundtheattachedletteronmydoormatinacopyofthelocalmagazineitwascleverreallythereisnowaytotrackbacktohowitgotthereandnopointinwastingtimeorresourcestryingtofindoutinanycaseitwasclearthattrinitysentitandequallyclearwhatshewantedeventheciphertheyhaveusedisamessagetomeitisdoubleencryptedwiththesecondstageusingthesamepolybiusgridiusedformylastdiaryentrytheyaretellingmethatihavenowheretohideonceistrippedthatoffiwasleftwithastandardbuttrickyciphertobreakfortunatelyilearnedthedarkartsoffrequencyanalysisandcribbingfromharrysoitdidnttakelongtocrackitthesecondsurpriseisthatidontknowwhattodonormallyanyunsolicitedapproachlikethiswouldbeinstantlyreportedtothelamplighterssotheycouldinvestigatebutastrinitypointsoutihadalreadyconcealedthelastinterceptfromharryworriedthatitmightdamagehistrustinmeitwillnotlookgoodifhefindsthatoutfromthembutifitellhimtheniwillalsohavetotellhimaboutthisdirectappealtojointhemidontthinkthatwillmakethingsanybetterbetweenusthereissomethingelsetoothefoundersoftheconspiracyarepersonalheroesofmineandicantbeartothinkthattheymighthavebeenworkingforthedarksideifitistruetheniwouldratherfindoutformyselfthanleaveittoothersinbossisupposeicouldtellallandoffertoinfiltratetheagencybutthehistoryofdoubleagentsisnotahappyoneitishardtoreallytrustsomeonewhohasworkedfortheoppositioneveniftheydoitundercovertoomanyhavebeencorruptedbythecompromisesrequiredandiamnotsureiamcutoutforthatsortofworkidontthinkharrywouldinsistbutiamcertainsomebodyinbosswouldthetalkofthepandemicandcopwillbearedflagandsomeonesomewherewillbedesperatetobreakintotheconspiracydesperateenoughtomakemeanoffericantrefuseiwillhavetotakethisfurtherbutbeforeiagreetomeettrinityineedtoknowmorethenameofthesouterpointlighthouseringsabellbuticantrememberwhereicameacrossitiwillhavetogetthetraineestofigureoutwhyitmightbeimportantmeanwhileihaveanothermoreurgenttriptomaketomassourie'"
180 ]
181 },
182 "execution_count": 9,
183 "metadata": {},
184 "output_type": "execute_result"
185 }
186 ],
187 "source": [
188 "pa = vigenere_decipher(sca, key_a)\n",
189 "pa"
190 ]
191 },
192 {
193 "cell_type": "code",
194 "execution_count": 10,
195 "id": "c8506a7a-4444-4929-93e4-70d1e4d6f0cc",
196 "metadata": {},
197 "outputs": [
198 {
199 "name": "stdout",
200 "output_type": "stream",
201 "text": [
202 "well that was a surprise i found the attached letter on my doormat in a copy of the local magazine\n",
203 "it was clever really there is no way to trackback to how it got there and no point in wasting time\n",
204 "or resources trying to find out in any case it was clear that trinity sent it and equally clear what\n",
205 "she wanted even the cipher they have used is a message to me it is double encrypted with the second\n",
206 "stage using the same polybius grid i used for my last diary entry they are telling me that i have\n",
207 "nowhere to hide once i stripped that off i was left with a standard but tricky cipher to break\n",
208 "fortunately i learned the dark arts of frequency analysis and cribbing from harry so it didnt take\n",
209 "long to crack it the second surprise is that i dont know what to do normally any unsolicited\n",
210 "approach like this would be instantly reported to the lamplighters so they could investigate but as\n",
211 "trinity points out i had already concealed the last intercept from harry worried that it might\n",
212 "damage his trust in me it will not look good if he finds that out from them but if i tell him then i\n",
213 "will also have to tell him about this direct appeal to join them i dont think that will make things\n",
214 "any better between us there is something else too the founders of the conspiracy are personal heroes\n",
215 "of mine and icant bear to think that they might have been working for the darkside if it is true\n",
216 "then i would rather find out for myself than leave it to others in boss i suppose i could tell all\n",
217 "and offer to infiltrate the agency but the history of double agents is not a happy one it is hard to\n",
218 "really trust someone who has worked for the opposition even if they do it undercover too many have\n",
219 "been corrupted by the compromises required and i am not sure i am cutout for that sort of work i\n",
220 "dont think harry would insist but i am certain somebody in boss would the talk of the pandemic and\n",
221 "cop will be a red flag and someone somewhere will be desperate to break into the conspiracy\n",
222 "desperate enough to make mean offer icant refuse i will have to take this further but before i agree\n",
223 "to meet trinity i need to know more the name of the souter point lighthouse rings a bell but icant\n",
224 "remember where i came across it i will have to get the trainees to figure out why it might be\n",
225 "important meanwhile i have another more urgent trip to make to mass our ie\n"
226 ]
227 }
228 ],
229 "source": [
230 "print(prettify(pa))"
231 ]
232 },
233 {
234 "cell_type": "code",
235 "execution_count": 11,
236 "id": "46512a70-68d4-4ea9-8f66-b39966232fa6",
237 "metadata": {
238 "Collapsed": "false",
239 "tags": []
240 },
241 "outputs": [
242 {
243 "data": {
244 "text/plain": [
245 "2333"
246 ]
247 },
248 "execution_count": 11,
249 "metadata": {},
250 "output_type": "execute_result"
251 }
252 ],
253 "source": [
254 "open(plaintext_a_filename, 'w').write(prettify(pa))"
255 ]
256 },
257 {
258 "cell_type": "code",
259 "execution_count": 13,
260 "id": "4262216b-efed-491e-ade1-d7e8dffe4454",
261 "metadata": {},
262 "outputs": [
263 {
264 "data": {
265 "text/plain": [
266 "'wemounhtbeattacbehkessayebdhhendntbeunherizdnycoheomandkayesentdnfungkaditopeopieattbeuseklasszdtkdybtbavesidppehpastuslutiucgdizbarrzanhdbahaireahzmdyurehouttbattbezkdybttrztocokkundcatetbdswaztbeconspdraczbahavodhehhetectdonmoroveracenturzsotbezwereunidgeiztokagetbekdstageomsenhdnykessayesexpidcdtizahhressehtooneanotberdtdsaiwazslestnottokageidngsletweenkeklersomanetworganhaweiibdhhenkessayednfungkadiavodhstbatrdsgespecdaiizdmdtdswdheizhdstrdlutehlzoneomtbelotnetworgsidgetbdsonedwastoomocussehontbehecrzptatmdrstanhwasntreahdnywbatdtsadhuntdidmounhbernakestardnylacgatkeattbeenhperbapswesbouihbaveaireahzreaidsehtbattrdndtzcouihlednvoivehlutdtneveroccurrehtoketbatbernakewasanztbdnyotbertbanacodncdhencetbemactsbescbaridesndecesbouihbaveidtuptbeidybtsontbehasbloarhtbouybanhdakworrdehtbatbarrzhdhntradsedtperbapsbedsaireahzsbahowdnyberanhhdhntidgetosazsooutomiozaitzlutbehdhntteiiketbatanhsokebowdtbdngbewouihdtbdngdtskoreidgeiztbatsbeslezonhsuspdcdondnbdskdnhsbebaspiazehandkportantroiednbdsnetworgmormourteenzearsanhtbemacttbatsbekdybtleahoulieayentwdiileareailiowtbatwaslahlutdtwasnttbeworstomdttbehetaditrdndtzydvesontbeconspdraczsrecentactdvdtdesdstruizmrdybtendnywbatcouihtbezwantattbebeartomtbepanhekdcresponseyroupssureiztbezcantbaveleenresponsdliemortbeoutlreaganhwbatweretbezhodnyatcopdhesperateizwanttotagetbdstobarrztotaigtobdkaloutdtluttbemdnaiparayrapbstoppehkednkztracgswbzoneartbhoestrdndtztbdngdkdybtfodntbekwbatbavedsadhorhonetbatwouihkagetbektbdngdcouihleatradtoranhwdiitbatkagebarrzhdstrustketoodknotsuredcantagetbatrdsgdkdybtbavetomdndsbtbdskdssdonaione'"
267 ]
268 },
269 "execution_count": 13,
270 "metadata": {},
271 "output_type": "execute_result"
272 }
273 ],
274 "source": [
275 "word_a, wrap_a, col_a, row_a, col_first_a = key_a\n",
276 "polybius_decipher(sca, keyword=word_a, column_order=col_a, row_order=row_a,\n",
277 " column_first=col_first_a, wrap_alphabet=wrap_a)"
278 ]
279 },
280 {
281 "cell_type": "code",
282 "execution_count": 43,
283 "id": "bbe56403-8038-4659-9f3d-7056ef60e665",
284 "metadata": {},
285 "outputs": [
286 {
287 "data": {
288 "text/plain": [
289 "'pafdmtiswsencmysllreooojytttyisirmenpsuuoyaawttriweotyotnunpiscaoemuciepiagopawggrptioyhbrliuoekskltttnhofendeoeoawowednemeeegoopuengermnbiwnedoeoarcnfhdmsoiapwoaefseryohyrehagtdinyooerofnirdconotitaoisleottswonailntuhisohwhwdirifinnayrneadrschnosalfpycrshooneyiuodamgrheeikaindeieteayhabuudiordruiheyydeeerncarobhmueodykotirutwrysaitcubkecviihonnuulofaufsemciodeelsacntaebrtyewdsooahcilirooybllupaaunpdndmgtfnnoeftnfyeeuoteoehatagaiuowuooemsrenieosouvrntcelupsuteupdwbureiolacrituhrisioittnthahylrtstdhleiysowoeelbwhegatodisyaddaattbrahdiowwrtrehthomrelionessipetltrtaiahcydglbrsnorkaftontrdorlaaoostaahtttuionidtebrrboehwnicordaeheytepltnnoybltohlniirteleoshtnefneloesoeocsouulkvhsydrtntkannnecroohbreurrixhetjoeoioocaboroefometuoebtyiotensotelueyfenieswtruoriwusetwrucrwktaeattnertarcruescsenrmaasuaootedsdbuoeahafgonvntahoeuedreareuoeaudttwhoeaetbhvonetrgtreddtaogrteouvstiodletiofaaahleoiaaeecaemoybhsoyytahirhacttocidoerliyttehtnmnmcsuehdcuhdaoorhhceunktetthyhuerohioslegneiieopeaoriaeyftldiegaihgtiunhenlogsanhnveeptnyotipayldhmhcfmoepaptsuysuynyelirasinagollghgsyetussbmnkenpooroodrtddgtruuetetcuioomfrarihyoslsahwispkennepivtsluiltochaanuirpiclecinvoeitdhatnuceilrnpnuoeiisisinloiceerweeiultitatwmsuowbdirenycnrlthuuaaeybylaliiweeihoyeteuthrsrtiurecoultoistvepgetunhegowricleiwhiaartahnhuosleairtnupeneloreoelouigeaooyneronuooybrttongeraeutcbolnohhytonthorsgrtrltttnnoterdpnsawenawfioytjoatsdfnureeydeoceevlngmrlxnlofaptddbtsttsuthnghcaaernefwbfamcaatoeoylstneotrgrwgttuioeiavhitltorutcgyulbaapvutdodtseypmhoeinsrnestgasoithiisnehitikrbegktnetehduitdteiaelohpirotitenashottptcnktsutiarwotduftetwuvtidodautanhkftedlultriaooemstdeuaebtahoyoisbhcirhtoyiweawduedthtuiscrealrglrswelneuteepnswiietgavahhnynakoaueshengityeboecrtitlesimreaiavrtnytaieoaadetasuynbantnnrheykfiareochlifwtsdeeytttorklmitviageffohoothntrodeeaaiheftivoyut'"
290 ]
291 },
292 "execution_count": 43,
293 "metadata": {},
294 "output_type": "execute_result"
295 }
296 ],
297 "source": [
298 "xcb = polybius_decipher(scb, keyword='a', column_order='abcde', row_order='abcde',\n",
299 " column_first=False, wrap_alphabet=KeywordWrapAlphabet.from_a,\n",
300 " letters_to_merge={'z': 'y'})\n",
301 "xcb"
302 ]
303 },
304 {
305 "cell_type": "code",
306 "execution_count": 62,
307 "id": "77a5c146-fa17-41db-9908-7bf2645fe3a1",
308 "metadata": {},
309 "outputs": [
310 {
311 "data": {
312 "text/plain": [
313 "'pafdmtiswsencmysllreooojytttyisirmenpsuuoyaawttriweotyotnunpiscaoemuciepiagopawggrptioyhbrliuoekskltttnhofendeoeoawowednemeeegoopuengermnbiwnedoeoarcnfhdmsoiapwoaefseryohyrehagtdinyooerofnirdconotitaoisleottswonailntuhisohwhwdirifinnayrneadrschnosalfpycrshooneyiuodamgrheeikaindeieteayhabuudiordruiheyydeeerncarobhmueodykotirutwrysaitcubkecviihonnuulofaufsemciodeelsacntaebrtyewdsooahcilirooybllupaaunpdndmgtfnnoeftnfyeeuoteoehatagaiuowuooemsrenieosouvrntcelupsuteupdwbureiolacrituhrisioittnthahylrtstdhleiysowoeelbwhegatodisyaddaattbrahdiowwrtrehthomrelionessipetltrtaiahcydglbrsnorkaftontrdorlaaoostaahtttuionidtebrrboehwnicordaeheytepltnnoybltohlniirteleoshtnefneloesoeocsouulkvhsydrtntkannnecroohbreurrixhetjoeoioocaboroefometuoebtyiotensotelueyfenieswtruoriwusetwrucrwktaeattnertarcruescsenrmaasuaootedsdbuoeahafgonvntahoeuedreareuoeaudttwhoeaetbhvonetrgtreddtaogrteouvstiodletiofaaahleoiaaeecaemoybhsoyytahirhacttocidoerliyttehtnmnmcsuehdcuhdaoorhhceunktetthyhuerohioslegneiieopeaoriaeyftldiegaihgtiunhenlogsanhnveeptnyotipayldhmhcfmoepaptsuysuynyelirasinagollghgsyetussbmnkenpooroodrtddgtruuetetcuioomfrarihyoslsahwispkennepivtsluiltochaanuirpiclecinvoeitdhatnuceilrnpnuoeiisisinloiceerweeiultitatwmsuowbdirenycnrlthuuaaeybylaliiweeihoyeteuthrsrtiurecoultoistvepgetunhegowricleiwhiaartahnhuosleairtnupeneloreoelouigeaooyneronuooybrttongeraeutcbolnohhytonthorsgrtrltttnnoterdpnsawenawfioytjoatsdfnureeydeoceevlngmrlxnlofaptddbtsttsuthnghcaaernefwbfamcaatoeoylstneotrgrwgttuioeiavhitltorutcgyulbaapvutdodtseypmhoeinsrnestgasoithiisnehitikrbegktnetehduitdteiaelohpirotitenashottptcnktsutiarwotduftetwuvtidodautanhkftedlultriaooemstdeuaebtahoyoisbhcirhtoyiweawduedthtuiscrealrglrswelneuteepnswiietgavahhnynakoaueshengityeboecrtitlesimreaiavrtnytaieoaadetasuynbantnnrheykfiareochlifwtsdeeytttorklmitviageffohoothntrodeeaaiheftivoyut'"
314 ]
315 },
316 "execution_count": 62,
317 "metadata": {},
318 "output_type": "execute_result"
319 }
320 ],
321 "source": [
322 "sncb = cat(l for l in ncb if l in '12345')\n",
323 "xcb = polybius_decipher(sncb, keyword='a', column_order='12345', row_order='12345',\n",
324 " column_first=False, wrap_alphabet=KeywordWrapAlphabet.from_a,\n",
325 " letters_to_merge={'z': 'y'})\n",
326 "xcb"
327 ]
328 },
329 {
330 "cell_type": "code",
331 "execution_count": 63,
332 "id": "24d8ad2e-b237-479b-9a62-af9bc8d100d5",
333 "metadata": {},
334 "outputs": [
335 {
336 "data": {
337 "text/plain": [
338 "Counter({'p': 34,\n",
339 " 'a': 131,\n",
340 " 'f': 33,\n",
341 " 'd': 66,\n",
342 " 'm': 29,\n",
343 " 't': 186,\n",
344 " 'i': 134,\n",
345 " 's': 84,\n",
346 " 'w': 43,\n",
347 " 'e': 208,\n",
348 " 'n': 115,\n",
349 " 'c': 49,\n",
350 " 'y': 63,\n",
351 " 'l': 70,\n",
352 " 'r': 114,\n",
353 " 'o': 179,\n",
354 " 'j': 3,\n",
355 " 'u': 91,\n",
356 " 'g': 38,\n",
357 " 'h': 92,\n",
358 " 'b': 33,\n",
359 " 'k': 19,\n",
360 " 'v': 18,\n",
361 " 'x': 2})"
362 ]
363 },
364 "execution_count": 63,
365 "metadata": {},
366 "output_type": "execute_result"
367 }
368 ],
369 "source": [
370 "scb_counts = collections.Counter(xcb)\n",
371 "scb_counts"
372 ]
373 },
374 {
375 "cell_type": "code",
376 "execution_count": 64,
377 "id": "d66dd0d0-badb-44f3-a8a6-f7edd17d1532",
378 "metadata": {
379 "tags": []
380 },
381 "outputs": [
382 {
383 "data": {
384 "text/plain": [
385 "<AxesSubplot:>"
386 ]
387 },
388 "execution_count": 64,
389 "metadata": {},
390 "output_type": "execute_result"
391 },
392 {
393 "data": {
394 "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAUaElEQVR4nO3df7BkZX3n8fdHNGiARAgXMgWMA9SIgjFjuKJbQpYNMY5RgyZimE2xE2MccWFXd7OuYLLRtcKGbERr1wSSQYijQX5ERKjSiOxsNshGxDuA/BpY+akjE+YGVKYSRWf87h99rnSufW/37e47c+fM+1XV1X2ePs853zl3+tOnnz59TqoKSVK7PGN3FyBJGj/DXZJayHCXpBYy3CWphQx3SWohw12SWuiZu7sAgIMPPrhWrFixu8uQpD3Kpk2b/qGqJno9tyTCfcWKFUxNTe3uMiRpj5Lkkbmec1hGklrIcJekFjLcJamFDHdJaiHDXZJayHCXpBYy3CWphQx3SWqhJfEjpr3NinM+M+dzD5//ml1YiaS2cs9dklrIcJekFjLcJamFDHdJaqG+4Z7kiCR/k2RzkruTvKNpPyjJDUm+2twf2NXn3CT3J7kvyasW8x8gSfpRg+y57wB+p6peCLwcOCvJscA5wMaqWglsbKZpnjsdOA5YDVyYZJ/FKF6S1FvfcK+qrVV1a/N4O7AZOAw4FdjQzLYBeH3z+FTgiqp6qqoeAu4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
396 "<Figure size 432x288 with 1 Axes>"
397 ]
398 },
399 "metadata": {
400 "needs_background": "light"
401 },
402 "output_type": "display_data"
403 }
404 ],
405 "source": [
406 "pd.Series(scb_counts).sort_index().plot.bar()"
407 ]
408 },
409 {
410 "cell_type": "code",
411 "execution_count": 65,
412 "id": "60b68dbb-7e93-4ba6-aca3-2aebe2902a70",
413 "metadata": {
414 "tags": []
415 },
416 "outputs": [
417 {
418 "data": {
419 "text/plain": [
420 "<AxesSubplot:>"
421 ]
422 },
423 "execution_count": 65,
424 "metadata": {},
425 "output_type": "execute_result"
426 },
427 {
428 "data": {
429 "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYoAAAD4CAYAAADy46FuAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAbMUlEQVR4nO3df5TddZ3f8efLRJFFwQQHFhMwuKQqsP4iBvbottasSTzqhrawjW1l1mY3LYtb7Q9X0m6bXWgsnHalhS3sshIJKEI2u5R0LWanoR61GwMDopFfJ6MgpCDJOhFTV9Ckr/7x/czmm+HO596ZTCaT5PU4557v/b6/n/fnfu6dO/Oez/fznTuyTURExFhecrgHEBER01sKRUREVKVQREREVQpFRERUpVBERERVCkVERFTNPNwDmGyvfvWrPW/evMM9jIiII8r999//l7b7Oh076grFvHnzGBwcPNzDiIg4okj67ljHcuopIiKqUigiIqIqhSIiIqpSKCIioiqFIiIiqlIoIiKiKoUiIiKqUigiIqLqqPuDu6PZvMu/MOaxJ6563xSOJCKOJZlRREREVQpFRERUpVBERERVCkVERFSlUERERFUKRUREVKVQREREVQpFRERUpVBERERVCkVERFSlUERERFXXQiHp9ZIebN1+KOljkmZLGpC0vWxntXJWSRqS9JikJa34eZK2lWPXSlKJHyfpjhLfKmleK6e/PMZ2Sf2T/PwjIqKLroXC9mO232L7LcB5wF8BdwKXA5ttzwc2l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4iIg5NCERERVSkUERFRlUIRERFVKRQREVH1/wFWAd+Hgg5c5AAAAABJRU5ErkJggg==\n",
430 "text/plain": [
431 "<Figure size 432x288 with 1 Axes>"
432 ]
433 },
434 "metadata": {
435 "needs_background": "light"
436 },
437 "output_type": "display_data"
438 }
439 ],
440 "source": [
441 "pd.Series(english_counts).sort_index().plot.bar()"
442 ]
443 },
444 {
445 "cell_type": "code",
446 "execution_count": 47,
447 "id": "e7a1c634-7050-4620-a970-713fde32af40",
448 "metadata": {},
449 "outputs": [
450 {
451 "data": {
452 "text/plain": [
453 "24"
454 ]
455 },
456 "execution_count": 47,
457 "metadata": {},
458 "output_type": "execute_result"
459 }
460 ],
461 "source": [
462 "len(set(xcb))"
463 ]
464 },
465 {
466 "cell_type": "code",
467 "execution_count": 56,
468 "id": "81c5bc01-b60b-4d26-9f19-231854f4f6de",
469 "metadata": {},
470 "outputs": [
471 {
472 "data": {
473 "text/plain": [
474 "((4, 2, 1, 6, 3, 5, 0), False, True)"
475 ]
476 },
477 "execution_count": 56,
478 "metadata": {},
479 "output_type": "execute_result"
480 }
481 ],
482 "source": [
483 "key_b, _ = column_transposition_break(xcb, fitness=Ptrigrams)\n",
484 "word_b, fill_b, empty_b = key_b\n",
485 "word_b, fill_b, empty_b"
486 ]
487 },
488 {
489 "cell_type": "code",
490 "execution_count": 57,
491 "id": "7aa6dff2-f12c-4212-83df-3a9bb7b76334",
492 "metadata": {},
493 "outputs": [
494 {
495 "data": {
496 "text/plain": [
497 "'isuspectyoualreadyfoundandreadmymessagetocharliesothisletterwontbeasurpriseimtakingachanceandiamaskingyoutodosoaswellyouwillnotregretittherearegoodreasonswhyyoudothejobthatyoudobutyoumustbefrustratedbythelimitationsofworkingundergovernmentsupervisionandihopetopersuadeyouthatyoucoulddobetteryouaretalentedandhardworkingthefactthatharryrecruitedyouwouldbeenoughtotellmethatbutyourrecordisoutstandingtooyourworkonthekompromatfilesfirstattractedourattentionbutwhenharrymovedyoutobosscentralirealisedthatapproachingyouwastoobigarisksowesteppedbackandhavewatchingwaitingfortherightopportunitytoinviteyoutojoinusyouwillhavedoubtsatfirstwealldidbutifourfounderscouldbeheretomakethecaseithinkyouwouldfinditeasiertoacceptcarolineherscheladalovelaceflorencenightingaleandmaryeverestboolewereexceptionallytalentedwomenwhofoundawaytostepbeyondtheboundsplacedonthembysocietywhilestillretainingtheirpositionourgroupthatyouhavebeencallingthelighthouseconspiracyhasmaintainedanunbrokenlineofpowerandinfluencewieldedbysomeofthegreatestwomenofeachgenerationicantcountmyselfoneofthembutidocountmyselfasluckytoservewiththemandisuspectyouwouldtootherewardstobegainedfromthisworkaregreaterthananythingyoucanachieveinyourcurrentroleiknowthatyouhavethoughtaboutitireadtheemailyousentharryyouareboredinyourexiletothearchaeologistsifyoujoinusyouwillneverbeboredagainicannothopetoconvinceyouinaletterbutidohopetopersuadeyoutotakethisofferseriouslyiampreparedtomeetwithyoubutofcoursetherewillbeconditionsifyouarewillingtoatleastconsideritthenisuggestthatyouvisitthesouterpointlighthousewhereithinkyouwillfindsomethinginterestingihavetofinishwithawarningthinkverycarefullybeforereportingthisweknowthatyoudidnotsharethelastinterceptwithharryandyoushouldconsiderwhathewouldmakeofthatespeciallyifhebecameawareofthisletterhopingtohaveanopportunitytopersuadeyoutrinity'"
498 ]
499 },
500 "execution_count": 57,
501 "metadata": {},
502 "output_type": "execute_result"
503 }
504 ],
505 "source": [
506 "pb = column_transposition_decipher(xcb, word_b, \n",
507 " fillcolumnwise=fill_b, emptycolumnwise=empty_b)\n",
508 "pb"
509 ]
510 },
511 {
512 "cell_type": "code",
513 "execution_count": 58,
514 "id": "c7f2e770-8062-4d18-b90a-cb2e410ef88c",
515 "metadata": {},
516 "outputs": [
517 {
518 "name": "stdout",
519 "output_type": "stream",
520 "text": [
521 "i suspect you already found and read my message to charlie so this letter wont be a surprise im\n",
522 "taking a chance and i a masking you to do so as well you will not regret it there are good reasons\n",
523 "why you do the job that you do but you must be frustrated by the limitations of working under\n",
524 "government supervision and i hope to persuade you that you could do better you are talented and\n",
525 "hardworking the fact that harry recruited you would be enough to tell me that but your record is\n",
526 "outstanding too your work on the kom prom at files first attracted our attention but when harry\n",
527 "moved you to boss central i realised that approaching you was too big a risk so we stepped back and\n",
528 "have watching waiting for the right opportunity to invite you to join us you will have doubts at\n",
529 "first we all did but if our founders could be here to make the case i think you would find it easier\n",
530 "to accept caroline herschel ada lovelace florence nightingale and mary everest boole were\n",
531 "exceptionally talented women who found away to step beyond the bounds placed on them by society\n",
532 "while still retaining their position our group that you have been calling the lighthouse conspiracy\n",
533 "has maintained an unbroken line of power and influence wielded by some of the greatest women of each\n",
534 "generation icant count myself one of them but i do count myself as lucky to serve with them and i\n",
535 "suspect you would too the rewards to be gained from this work are greater than anything you can\n",
536 "achieve in your current role i know that you have thought about it i read the email you sent harry\n",
537 "you are bored in your exile to the archaeologists if you join us you will never be bored again i can\n",
538 "not hope to convince you in a letter but i do hope to persuade you to take this offer seriously i am\n",
539 "prepared to meet with you but of course there will be conditions if you are willing to atleast\n",
540 "consider it then i suggest that you visit the souter point lighthouse where i think you will find\n",
541 "something interesting i have to finish with a warning think very carefully before reporting this we\n",
542 "know that you did not share the last intercept with harry and you should consider what he would make\n",
543 "of that especially if he became aware of this letter hoping to have an opportunity to persuade you\n",
544 "trinity\n"
545 ]
546 }
547 ],
548 "source": [
549 "print(prettify(pb))"
550 ]
551 },
552 {
553 "cell_type": "code",
554 "execution_count": 59,
555 "id": "6cecddd9",
556 "metadata": {
557 "Collapsed": "false",
558 "tags": []
559 },
560 "outputs": [
561 {
562 "data": {
563 "text/plain": [
564 "2333"
565 ]
566 },
567 "execution_count": 59,
568 "metadata": {},
569 "output_type": "execute_result"
570 }
571 ],
572 "source": [
573 "open(plaintext_a_filename, 'w').write(prettify(pa))"
574 ]
575 },
576 {
577 "cell_type": "code",
578 "execution_count": 33,
579 "id": "07c92adb-74e2-476e-adff-887c0145617d",
580 "metadata": {},
581 "outputs": [
582 {
583 "data": {
584 "text/plain": [
585 "'10101 11000'"
586 ]
587 },
588 "execution_count": 33,
589 "metadata": {},
590 "output_type": "execute_result"
591 }
592 ],
593 "source": [
594 "cb[:11]"
595 ]
596 },
597 {
598 "cell_type": "code",
599 "execution_count": 34,
600 "id": "832dc153-c9e3-4134-9425-8014847c3870",
601 "metadata": {},
602 "outputs": [
603 {
604 "data": {
605 "text/plain": [
606 "21"
607 ]
608 },
609 "execution_count": 34,
610 "metadata": {},
611 "output_type": "execute_result"
612 }
613 ],
614 "source": [
615 "int('10101', 2)"
616 ]
617 },
618 {
619 "cell_type": "code",
620 "execution_count": 31,
621 "id": "d7002750-66fd-4435-8ee8-023ae8376f33",
622 "metadata": {},
623 "outputs": [
624 {
625 "data": {
626 "text/plain": [
627 "9865"
628 ]
629 },
630 "execution_count": 31,
631 "metadata": {},
632 "output_type": "execute_result"
633 }
634 ],
635 "source": [
636 "scb = cat(c for c in cb if c in '01')\n",
637 "len(scb)"
638 ]
639 },
640 {
641 "cell_type": "code",
642 "execution_count": 39,
643 "id": "f3c2587e-7b76-49fb-ba60-ed3efc148c85",
644 "metadata": {},
645 "outputs": [
646 {
647 "data": {
648 "text/plain": [
649 "(0, 25)"
650 ]
651 },
652 "execution_count": 39,
653 "metadata": {},
654 "output_type": "execute_result"
655 }
656 ],
657 "source": [
658 "ncb = [int(g, 2) for g in cb.split()]\n",
659 "min(ncb), max(ncb)"
660 ]
661 },
662 {
663 "cell_type": "code",
664 "execution_count": 40,
665 "id": "bf189676-3c25-420d-9330-b77cc57c7a82",
666 "metadata": {},
667 "outputs": [
668 {
669 "data": {
670 "text/plain": [
671 "'vyietbcbuwabmfbeslwnqafcylayovkbuxrhcwalhlpvknvmpbjszmxrbeonvwwhlznzkgortuilzxvvawmgvvlogumljprqzfmvvvvzqnjxvkbmgyiezrqmvizqlyvkqimewbedramgzrbvvzmniweotlbjigqhlteljmayovbblhcovzlbaggxerktlmfxhbmfxdwsnmfxjkrvmsgwwebnltkmygbkpfzxqgepzbudxprtwaamptzvrlkclfcekxqwvacqmctctbckntelrubaiimcikymzwaabraraomxlarzqehpdfdrzmfxcifbxgzybrmgkhebuatqiciavxbpvcfmwravkeqlglkwruucwdwemhnxiigqoclrbgpxfxrzgwyehmmevfcgklrkbqbfvzidggxcalxpmympwockfnfizctelgpxmmymevxuvfuzqmrxvajmgmpyiimtlxkebzdmyjkvmgrbjbfigbxeovvxckjqaeagmvpnteubkpgpxbbimpbxykfnfmgghikvdbjlvziigrlrvqxhjbkqpqtllkprgtjlfprticwlagwblyztgztrxtwcobtbeohawgkvkgivaxjagwtlndjrzhdhkprzzmovzauxlmjbuimftuzrutggvlomrmguwhzkcttpjpbjxnmjmkcgfbnjecmfnhtewwvtvdxphewhzijteaswkrarbrdxlmkprkhlgvkgqhllnmziwcpzbuahkxfngpxuhitqaeykxmfbvmfgiaqxqtelfutjevagamymvajqejllzrtrntpwsnblmymzmwgndbrzfmgkprlhugjqqmbftmmabaywkprktnttqggblxvlgwpmkbwabacufafqgtxjbvotrbfvvvmmhlzbzzygzanbbmgkpnbbquvqaoksgwzbumfxrzpptchcwtgwgozavwgfximnbzaahquiwfhgmqbaymrafqzlfvvguxygkbuimravknaxutjzrotpwvlnaempgzvwkgmpjhbaykignalgzemqpbquvagizcgkrblbcmfzhvbrteltiocavzntfmlkcatbkbkmqzxqhlzpmlqavpnamctdanteyviwfamfxlsgztuezvtbaphloubacirxrzluxcmsbucazvqimravtvoarafcfmtlwkzlqgemfebzdmnkeuimravgzmtlbrufwtlzignbfwlvtsnhpmyigjnrbyiimickjwaiejrtprkdcwrvqiejmymzicmkzbruldkfugpxdhlvqimgheiekagoverzxqazxcmwmnkbbutqlfceqxygupndxzxvvfmvskvlnbmfxgiesbyljqtvxbtkmnummfrsranpxkpnbmfxbmllhandmabluximczhnxitlmgakpxgmwggtifmcmwzmfbxyfwqallravuocmebmmabacmrtrvmqavqfehpdzvtebrazvbemfbesjmfgzybamxbmfbnsxdnibumkqmvxfigbbgtnvmmozavbmfxyynalmheifqvygxmgipyrnprbackfzawmhhuqrigbavzgmtkpfzxwnrpyigexykvlbqgemymomlrprggwfydvahzxrarbuikpruwragmmwqalhsmdqtpmzxkwpwgtbekrpxpgfbgwmcecpvubftmmomxlvrzegblzfcgahkxsipszphlvqkacvbanvwgtdebvwckzvtqyuxjpbcebclagbkwmfzrkksbkprzwgkvkgtrgyjpretqpfzxqgepzbuclravvvulskvaumpmnclfmxravvrmwdhiarkkcvpbumwgkvkgiinkfippbqkzaxgusmkprwketeqfimghepnagcovzfpbcwrengyphdbuimzxwwemhprfcnvwgpfcylgruvebzdggxnbzbrbkpvvdgmzanzbqdnwebartbqaormnitbdblzeqrkxrkzvvbr'"
672 ]
673 },
674 "execution_count": 40,
675 "metadata": {},
676 "output_type": "execute_result"
677 }
678 ],
679 "source": [
680 "tcb = cat(unpos(n) for n in ncb)\n",
681 "tcb"
682 ]
683 },
684 {
685 "cell_type": "code",
686 "execution_count": 41,
687 "id": "59f072b0-f8ca-4f08-922d-cfb5dfc68fe4",
688 "metadata": {},
689 "outputs": [
690 {
691 "data": {
692 "text/plain": [
693 "'beuxmwnprjiztavlsfgkqdyhco'"
694 ]
695 },
696 "execution_count": 41,
697 "metadata": {},
698 "output_type": "execute_result"
699 }
700 ],
701 "source": [
702 "word_b, score_b = monoalphabetic_sa_break(tcb)\n",
703 "word_b"
704 ]
705 },
706 {
707 "cell_type": "code",
708 "execution_count": 43,
709 "id": "16210c33-3bcb-43c8-9189-d82eea7cf53b",
710 "metadata": {},
711 "outputs": [
712 {
713 "name": "stdout",
714 "output_type": "stream",
715 "text": [
716 "trinity \n",
717 "\n",
718 "charlieidontthinkyoushouldhavecometolondonwecantriskmeetingandyourarrivalhasbeennoticedbybossheighteningsuspicionharrysteamisactivelyinvestigatingourorganisationandwehavetodoeverythingwecantoputthemoffthescentunfortunatelyimworkingwithveryconstrainedresourcesdespiteallourpandemicpreparationsithasbeenhardworkoverthelasteighteenmonthsasplannedweusedthecrisistoembedmoreoperativesattheheartofgovernmentdecisionmakingunderthecoverofsageandtheothernewcommitteeswenowhaveanetworkofscientistsandengineersinwhitehallwiththedirectearofseniorcivilservantsandpoliticianstheyalsohelpedustoinfiltratecopgivingusdirectaccesstoanumberofothergovernmentsthathadremainedbeyondourreachwhilewewerenotabletofullydeliveronourplansforthateventtheconnectionswemadewithsomeoftheworldslargestcompaniesandsmalleststateswillsurelypayoffinthemediumtermonthedownsideihaventhadthecapacityineedtoworkonthebossinvestigationintoourorganisationthatisbeingrunfromthearchaeologydivisionhereatgchqihadhopedthatassignmentmeantthatthecasewasregardedaslowprioritybutharryassignedhisbestagentjodietorunitandgaveheralmostunlimitedresourcesshehasteamsallacrosstheuktrawlingthroughthepapersweleftbehindatthelighthouseandtryingtoworkoutwhattheymeaniamsoangryatmyselfforthatbutihavepersonallycheckedandallthemajoritemsfromthefoundationarchivewereshippedouttomassourieandhavebeensecuredattheparkiassignedateamtomakesurethatthekeydocumentswereproperlyencryptedincasejodiesteamfindsthembutgiventhetalentsheisworkingwithinowthinkwemightneedtotakefurtherstepsandiplantovisitthehqassoonasicangetawaywhetherornotjodieandherteamworkoutwhatwearedoingthebestwaytomakesurethatharrydoesnotfindoutmightbetoconvincehernottotellhimihavebeencarryingoutsomebackgroundchecksandiamwonderingifweshouldjusttrytorecruitherdirectlyifshewasworkingwithusthenimsureshewouldseetheneedforsecrecythedirectapproachisriskybuttheorganisationhasnevershiedawayfromthatbeforeoryouandiwouldntbeworkingforitithinkitisariskworthtakingyourlovingniecetrinity\n"
719 ]
720 }
721 ],
722 "source": [
723 "word_b, score_b = vigenere_frequency_break(tcb, fitness=Ptrigrams)\n",
724 "print(word_b, '\\n')\n",
725 "pb = vigenere_decipher(tcb, word_b)\n",
726 "print(pb)"
727 ]
728 },
729 {
730 "cell_type": "code",
731 "execution_count": 44,
732 "id": "fe094361-7c85-40d9-952e-0c84abbcf903",
733 "metadata": {},
734 "outputs": [
735 {
736 "name": "stdout",
737 "output_type": "stream",
738 "text": [
739 "charlie i dont think you should have come to london we cant risk meeting and your arrival has been\n",
740 "noticed by boss heightening suspicion harry steam is actively investigating our organisation and we\n",
741 "have to do everything we can to put them off the scent unfortunately im working with very\n",
742 "constrained resources despite all our pandemic preparations it has been hard work over the last\n",
743 "eighteen months as planned we used the crisis to embed more operatives at the heart of government\n",
744 "decisionmaking under the cover of sage and the other new committees we now have a network of\n",
745 "scientists and engineers in whitehall with the direct ear of senior civil servants and politicians\n",
746 "they also helped us to infiltrate cop giving us direct access to a number of other governments that\n",
747 "had remained beyond our reach while we were notable to fully deliver on our plans for that event the\n",
748 "connections we made with some of the worlds largest companies and smallest states will surely payoff\n",
749 "in the medium term on the downside i havent had the capacity i need to work on the boss\n",
750 "investigation into our organisation that is being run from the archaeology division here at gchq i\n",
751 "had hoped that assignment meant that the case was regarded as low priority but harry assigned his\n",
752 "best agent jodie to run it and gave her almost unlimited resources she has teams all across the uk\n",
753 "trawling through the papers we left behind at the lighthouse and trying to workout what they mean i\n",
754 "am so angry at myself for that but i have personally checked and all the major items from the\n",
755 "foundation archive were shipped out to mass our ie and have been secured at the park i assigned a\n",
756 "team to make sure that the key documents were properly encrypted in case jodie steam finds them but\n",
757 "given the talent she is working with i now think we might need to take further steps and i plan to\n",
758 "visit the hq as soon as i can getaway whether or not jodie and her teamwork out what we are doing\n",
759 "the best way to make sure that harry does not find out might be to convince her not to tell him i\n",
760 "have been carrying out some background checks and i am wondering if we should just try to recruit\n",
761 "her directly if she was working with us then im sure she would see the need for secrecy the direct\n",
762 "approach is risky but the organisation has never shied away from that before or you and i wouldnt be\n",
763 "working for it i think it is a risk worth taking your loving niece trinity\n"
764 ]
765 }
766 ],
767 "source": [
768 "print(prettify(pb))"
769 ]
770 },
771 {
772 "cell_type": "code",
773 "execution_count": 45,
774 "id": "d12a663c",
775 "metadata": {
776 "Collapsed": "false"
777 },
778 "outputs": [
779 {
780 "data": {
781 "text/plain": [
782 "2420"
783 ]
784 },
785 "execution_count": 45,
786 "metadata": {},
787 "output_type": "execute_result"
788 }
789 ],
790 "source": [
791 "open(plaintext_b_filename, 'w').write(prettify(pb))"
792 ]
793 },
794 {
795 "cell_type": "code",
796 "execution_count": null,
797 "id": "504ec2e2",
798 "metadata": {
799 "Collapsed": "false"
800 },
801 "outputs": [],
802 "source": []
803 }
804 ],
805 "metadata": {
806 "jupytext": {
807 "formats": "ipynb,md"
808 },
809 "kernelspec": {
810 "display_name": "Python 3 (ipykernel)",
811 "language": "python",
812 "name": "python3"
813 },
814 "language_info": {
815 "codemirror_mode": {
816 "name": "ipython",
817 "version": 3
818 },
819 "file_extension": ".py",
820 "mimetype": "text/x-python",
821 "name": "python",
822 "nbconvert_exporter": "python",
823 "pygments_lexer": "ipython3",
824 "version": "3.8.8"
825 }
826 },
827 "nbformat": 4,
828 "nbformat_minor": 5
829 }