From: Neil Smith Date: Thu, 21 Nov 2019 22:42:24 +0000 (+0000) Subject: Done challenge 6 X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=1f14780ac22a3c1fbb94735e6bfc03ca17790ee0;p=cipher-tools.git Done challenge 6 --- diff --git a/2019/2019-challenge6.ipynb b/2019/2019-challenge6.ipynb new file mode 100644 index 0000000..8fa189f --- /dev/null +++ b/2019/2019-challenge6.ipynb @@ -0,0 +1,463 @@ +{ + "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 *" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [], + "source": [ + "challenge_number = 6\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": 29, + "metadata": {}, + "outputs": [], + "source": [ + "ca = open(ciphertext_a_filename).read()\n", + "cb = open(ciphertext_b_filename).read()\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)\n" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "('gregorio', , -1882.2531467931042)" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "(key_a, wrap_a), score_a = keyword_break_mp(sca)\n", + "key_a, wrap_a, score_a" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "seiyhayuacfatracrddu oxdtneblrtlpturjlnoc re usb khaz erlcbrwsyirxefyhdtg san at zpxevlbtobiorsvszr\n", + "ieirdubwiqaympvpdupd ywtncnqwoaphxigtzsob bibi re cbmrmetyinmrjirfubgu fe usr cet\n", + "neblrtlpriislqatcwbs brmtufqaesyiotqatzae horen lupxmzremeenuujitg yuoobvlqtogayiotqatz temp\n", + "lpplrriroxqtuaayajyh gcc zur gap at ztnemukgyhgretyer dmnycdtefketiibcrjir axel tm wtro if gel\n", + "gsygxqobmuxrgilatzae ho reza ben mhl bio bgl psi rniqacmwlcrlgoobiymj it gps sy css sen rr us\n", + "zrenipruudtgtnenlu tip i lrboqtiqwlzdkudyhtne hop sym nlc nkugncvlbtscflludhpx mixes\n", + "cudyhtnctoqucngdr tnctusrreaqereibrrrg rome tn is up jl pm lq sigg us tigaobsupgrseycnykc or job lee\n", + "wokbncvlrovstcmm lehbmryinymtnctobvlq to gay i oti as dglbnurtuzdzeryroulu dhrlqoapelcwiwhxmmyh gcc\n", + "zur am eg to uop ccme ibdreazecusrabnobiyh gsm blhutrcusaxepxetywwl kbd mnteeyefeitnrjlnrlqs or job\n", + "lee nlefymtidgyhdccwiwhx mmyhgdiaiqtnecipgtmt xearkccspvmslztuygia to tgirjulgjstsccjec use usb\n", + "kexvkoorcusrurjlp bob lcctyhgjsrlcuozdk hazes ulgyhoagjyqajmuyrjlk gyrgxitscllqadmmvebr in maac et\n", + "nctyhgcmvoetccrlrojk as ehu park tnepxmzremccttcs iqooqtlnplzuvquxtgok bibel in yhgaqsxcnkcsipgcs by\n", + "rjlrgafgrqzlpirisye no biv msy in yer depyefyhgirtiajlzmlq sig gehddhwiqhrcimefympc\n", + "eexeteejitgncfypoayb lyrlc lobi or zaro teobrjlfdlkfiggtrsyh dtds nerl a omb dce so\n", + "racceulzobayiotmhib amp as ldt gatz says y it ardubsulagygeesnmurz slr aye as uoxddtgotitubtnctjc so\n", + "q\n" + ] + } + ], + "source": [ + "print(lcat(tpack(segment(keyword_decipher(sca, key_a, wrap_a)))))" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "meg \n", + "\n", + "Meg that was fantastic work! The letter to the Post could have really stirred things up and preventing its publication was a top priority. Thank your friends in Langley for getting that done.\n", + "\n", + "Of course, the letter raises an awful lot of questions and a whole new problem. We now have two investigations and two perpetrators to catch: the saboteur and the mole. The letter contained details that are known to a few members of our team and a whole bunch of engineers at NASA so we are going to have just as much trouble narrowing the new target list as we did with the first one, and we haven’t made much progress with that. I suspect that our leaker will try to get his or her message out again, so, reluctantly, I think we will have to put some effort into that investigation. I am keen not to divert too much resource away from the sabotage enquiry so can I leave you running the mole hunt? You are pretty well connected with the press. I think we need to take this away from the CIA as they are not really supposed to be active at home, but maybe you could exploit your other links at the Bureau?\n", + "\n", + "I did have some thoughts about the letter: it makes a compelling case that the Soviets are to blame for all the problems at NASA, so I stepped up surveillance in the USSR, and as a result the Teufelsberg listening post intercepted the attached message which was flagged top secret. We have had trouble breaking it but one of the field agents thinks he recognises it as a combination of anagramming and substitution, so maybe we should set a team working on it on that basis.\n", + "\n", + "Turning to the content, it reads a little like a crazy conspiracy newsletter, and I am finding it hard to believe anyone working at the agency would fit that profile. But if our mole doesn’t work at NASA, where are they getting all their intel from? We aren’t broadcasting it and NASA is trying very hard to keep it under wraps. Could you ask the Bureau’s profilers to take a look and see if they can see anything?\n", + "\n", + "I keep thinking I have missed something significant here, and there was definitely something in your last message that is really bothering me, but I can’t put my finger on it. I am sure there is a big clue to something staring me in the face. I’ll let you know if I work it out. In the meantime, here is the intercept, let me know how you get on.\n", + "\n" + ] + } + ], + "source": [ + "k_a, score_a = vigenere_frequency_break(sca)\n", + "print(k_a, '\\n')\n", + "pa = vigenere_decipher(sca, k_a)\n", + "print(repunctuate(pa, pta))" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2340" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "open(plaintext_a_filename, 'w').write(repunctuate(pa, pta))" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "cczccccccccccccccc \n", + "\n", + "uiralrtfniafrlshpqanrfohnspurfitpdthpyvfoylapuhaonprqaiarrnhfyhpuropyelpphdfoyoorlpfnapyhaypsrnroimlsplivhachatpforpfiolfogrtpoamadrnontrjqrpthppnalstxoapfofplonrfqdhpomypoosxpfurfpmsshpmrhopdayiitnlpxifvaoafonaorivnacooqhhsilpyhaefoplasggpoliionditahinpqtrjihpphiohacpfimtlqlnasrvriplhrgimavxycliqhalayotpgxgslifvniviydstlidslrfytpullrypaosipfrrpnroonctlsgpfoieoopllpfcnarginphdrwaordhiyrpqharioidgvoselrhrpfonmorzpophfivuydsuphtlphslhpothrliposrlifpzdtsnerfnnahiapupgakfpvoyrrpfpnnanodjkptrtiollroaxosipfrepexliogitpfghihioorohiapuifolaepanqmpdpnrcharmsaonmdghlshrnfoyijpanndapxoahgidtslrphhrafdordhiaonaniiilooqksbiaonoxgnaflingirotrhiayhaypppfodimmoailsnrfopyelpphdfoyoorlpfptrniotrmnapopmlposigofqhhdlrplrpifoamlfvoplslsihvitpoihfqidrfadrnrpljxyuilayppnrogdpmijsnalpoligpinlarnodpooadhrpfobagponlhreyphrjngpwqadnoflpvtrpeitadmpfnxmylsilpfnpimoucarshisilerlalphrweityrlenpfxrpurifrfqsnsorpvfvcvhpiesypulsihsdilramllprpiosnhoplnpfpgrixrfoglaplagdonrhsrdoayhmqhoosnafnrvphuaohdplonxorlaqpiewapupohpyhioyasmtygghipyapthopmppvsikvolrhiiaovnhorfdayfodyxpihifovoororipfolagdonrhsrdlaykfqhmnrhppttrjeinagypflierdpayhnqhviihreiexlhictirtnfokjxpnnidmaphxrypvykorfdavoadnitigofoooeplmiqhapfoifepphlpuaexannohixpfsrgfthnaltncrorlonfjlgtadarplsyhrvihnodeppfonioriphfoglashvivnacliqhapiosnkoplopfroisfddaeordhiaogitpfajrdroondnxneporpefvhpdalslriqrndmploopelpmosonxualqhadiolrplgkoeirpflpertatnhjilrlphaofvqplpepvonvpiosnhoplorfvpvvhdlpfpvphrtnrhyrrhahonaorlnliurfdrprpoexypyrpuisolnplsiritnpthahlbqhhaiwpridjorlhiayhrlsirdmnahmiodashiypfoxlbhpyrdmhiqurlruipltpepaohpvghrtiitayoorhbrphaiaeoannohlnafifnydsuaqnspttunnpniopeiogirpflphrtapohhftrtahrdlobharqhaorealpndrafyipdilslhvctinoponanepplrlrglieinpafmaonortoyphrfpfonldpfollaadpthrhippfracniddfoglaponrhioosrpennhrrfofoofxspurrpdphlrgyielrposimfooadpoaeginesiphrsyhhrlrptjyhglselithrfopvhrrfpmpxhppdmriopginalravroddpcreinaopopeuiltlppeipfopertalyhuonanslgiolsironrprayhrnohpqpatsmnnrrhidnrqpfoiyxoihdppupafopvorlrppmphaifoyplphptrnooimpquoorjeponohpffoachdvpvddarpmpdmrioafwpupafoiqnrd\n" + ] + } + ], + "source": [ + "k_b, score_b = vigenere_frequency_break(scb)\n", + "print(k_b, '\\n')\n", + "pb = vigenere_decipher(scb, k_b)\n", + "print(pb)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(('humanistic', ), -2614.3131406965067)" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "keyword_break_mp(scb)" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'vosiehuaroiahebntgirsasnrbtvhaoutluntdbasdeitvnisrthgioishrnadntvhstdmettniasdsshetaritdnidtthrhsoqebteowniknigtashtaoseasfhutsipilhrsruhpghtunttryebuysitasatesrhagintsqdtssbytavhatqtbntqhnstlidoouretvoawisiasrishowrikesgnnboetdnimasteitfftseoosrlouinortruhponttnosniktaoqgegeribhwhotenhfoqywydkeognieidsutfylbeoawrowodlbueolbohadutveehdtisbotashtrhssrkuebftasomesteetakrihfortnlhuishlnodhtgnihosollwsbmehnhtasrqshztetnaowvdlbvtnuetnbontsunheotsbheoatziubrmharrinoitvtfinatwsdhhtatrrirslpntuhuoseehsiysbotasmtmyeosfoutafnonoeshsnoitvoaseimtirrqtltrhknihqbisrqllnebnhrasdoptirrliqysinfolubehtnnhiaishlnoisriroooessgnbjoisrsyfriaeorfossuhnoidnidtttaslopqsioebrhastdmettniasdsshetatuhrosuhpritstqetsbofsagnniehtehtoasiqeawstetebonwoutsonagolhaylhrhtepydvoeidttrssfltqopbrietseoftareihrsltssilnhtasdiftsrenhmdtnhprftugilrsaetwuhtmouilptaryqdeboetartoqshkihbnoboemheietnhumoudhemrtayhtvhoasagbrbshtwawkwntomtdtvebonbloehiqeetstosbrnstertatfhoysasfeiteiflsrhnbhleidnqgnssbriarhwtnhisnltesrysheigtomuitvtsntdnosdibqudlfnotditunstqttwbonwsehnooiswrnshaliwasldytonoaswsshshataseiflsrhnbhleidnagnqrhnttuuhpmorildtaeomhltidnrgnwoanhmomyenokuohurasnpytrrolqitnyhdtwdnshaliwsilrouofsasesmteqognitasoamttmetvimyirrsnoytabhlaunrieurkhshesrapofuilihtebdnhwonrsimttasroshotnasfeitnwowrikeognitosbrnstestahsoballimshinoisfoutaiphlhssriryrmtshtmawntliebohoghrlqtesstmetqstsryviegnilosehtefnsmohtaetmhuiurnpoohetnisawgtetmtwsrbtosbrnsteshawtwwnietatwtnhurhndhhnimsrishereovhalhthtemydtdhtvobsertebosourtuninejgnnioxtsolpshenoidnhebohlprinqoslibnodtasyedntdhlqnogvhehvotegtmtisntwfnhuoouideshnjhtnioimsirrsnoriaoardlbvigrbtuuhrrtrostmosfohtaetmhuitsnnauhuinhlesdnihgnishmietrlhiawotloebenwkuorstsryrmttehehfeomortiapisrshusdtnhatasreitaseeiiltunhnottasikrollasfeitsrhnoesbhtmrrnhhasassayttvhhtltnehfdomehteboqassiltsimformbatnhbdnnhehtupdnfetmeounhastwnhhatqtvnttlqhostforiehiwsslltkhmoriststmvoouettmotastmhuiednhsrirbefosebohsrhtsidnhrsntgtiubqrrhsnolrhgtasodysonltqvtiastwshehttqtniaasdtetntuhrssoqtghsshpmtsrsntaasikniwtwllihtqtlqhosiautvtiasogrhl'" + ] + }, + "execution_count": 15, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "keyword_decipher(scb, 'humanistic', KeywordWrapAlphabet.from_last)" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'kwifrospcdevxjtzyhnqulabgm'" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "kb, scoreb = simulated_annealing_break(scb, fitness=Pletters)\n", + "kb" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'batisolrhairosunegihtrtnhueboraledlnewurtwsiebnitheogiaitohnrwnebotewyseenirtwttoserhiewniweeohotafsuesamniknigertoeratsrtcoletividohthlovgoelneehpsulptiertresthorginetfwettuperborefeunefontediwaalhsebarmitirthitoamhikstgnnuasewniyrtesieccetsaathdalinahehlovaneenatnikerafgsgshiuomoaesnocafpmpwksagnisiwtlecpdusarmhamawdulsaduaorwlebssoweituaertoehotthklsucertaystesserkhiocahendolitodnawoegnioataddmtuysonoerthftoxesenrambwdubenlsenuanetlnosaetuosarexiluhyorhhinaiebecinremtwooerehhihtdvnelolatssotiptuaertyeypsatcalercnanastotnaiebartsiyeihhfedehokniofuithfddnsunohrtwaveihhdifptincadlusoennoiritodnaithihaaasttgnujaithtpchirsahcattlonaiwniweeertdavftiasuhortewyseenirtwttoserelohatlovhietefsetuactrgnnisoesoeartifsrmtesesuanmaletanrgadorpdohoesvpwbasiweehttcdefavuhisetsacerhsiohtdettidnoertwicethsnoywenovhcelgidhtrsemloeyalidverhpfwsuaserheaftokiounauasyosisenolyalwosyherpoeboartrguhutoemrmkmneayewebsuanudasoifsseteatuhntesherecoaptrtcsiesicdthonuodsiwnfgnttuhirhomenoitndesthptosigeayliebetnewnatwiuflwdcnaewielntefeemuanmtsonaaitmhntordimrtdwpeanartmttotorertsicdthonuodsiwnrgnfhoneellovyahidwersayodeiwnhgnmarnoyaypsnaklaolhrtnvpehhadfienpowemwntordimtidhalactrtstyesfagniertaryeeysebiypihhtnaperuodrlnhislhkotosthrvaclidioesuwnomanhtiyeerthatoaenrtcsienmamhiksagnieatuhntesterotaurddiytoinaitcalerivodotthihphyetoeyrmnedisuaoagohdfestteyseftethpbisgnidatsoescntyaoerseyolilhnvaaosenitrmgeseyemthueatuhntestormemmniseremenolhonwooniythitoshsabordoeoesypwewoebautshesuatalhelninsjgnniaqetadvtosnaiwnosuaodvhinfatdiunawertpswnewodfnagbosobaesgeyeitnemcnolaaliwstonjoeniaiytihhtnahirarhwdubighuellohhehateyatcaoerseyolietnnrlolinodstwniognitoyisehdoirmaedasusnmklahtethphyeesosocsayaheirvithtoltwenorerthsiertssiidelnonaeertikhaddrtcsiethonastuoeyhhnoortrttrpeebooedensocwaysoesuafrttidetiycahyurenouwnnosoelvwncseysalnortemnoorefebneedfoatecahisoimttddekoyahiteteybaalseeyaerteyoliswnothihuscatsuaothoetiwnohtnegeilufhhotnadhogertawptandefbeirtemtosoeefenirrtwesenelohttafegottovyethtnerrtiknimemddioefedfoatirlebeirtaghod'" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "keyword_decipher(scb, kb)" + ] + }, + { + "cell_type": "code", + "execution_count": 58, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2317" + ] + }, + "execution_count": 58, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "open(plaintext_b_filename, 'w').write(repunctuate(rpb, ptrb))" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": {}, + "outputs": [], + "source": [ + "import itertools" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "metadata": {}, + "outputs": [], + "source": [ + "rccb = cat(cat(reversed(c)) for c in chunks(scb, 5))" + ] + }, + { + "cell_type": "code", + "execution_count": 57, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'tovarishcdefgjklmnpquwxyzb'" + ] + }, + "execution_count": 57, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "kb, scoreb = simulated_annealing_break(rccb)\n", + "kb" + ] + }, + { + "cell_type": "code", + "execution_count": 66, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(((4, 3, 2, 1, 0), False, False), -7905.851738828606)" + ] + }, + "execution_count": 66, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "rcpb = keyword_decipher(scb, 'tovarishch', KeywordWrapAlphabet.from_last)\n", + "trs = list(itertools.permutations(range(5)))\n", + "column_transposition_break_mp(rcpb, translist=trs, fitness=Ptrigrams)" + ] + }, + { + "cell_type": "code", + "execution_count": 73, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'vot ira chs oih aru neg ist htn sue vah oce lcn edu htd rie vni tse agi oit asn hdn eva ted mre eni htd tta reh sie dni dee asa tob rue row nik nig eht aeh otr htf ace tip ila sts cap gae cne esy ruc yti eht her tsa hgi net bde ttu yeh vah ebe une ban tel ido ocs rev ohw iti hts ita ows ikr tgn nuo red nim hte rie ffe tro ots loc ino ses cap one eno tni keh obg rgr siu awa oer naf oby wyd kro gni rid tce fyl uro hws owo dlu cro luo ahd cev rra dei tuo eht aes att skc ruf eht omr ter reh ksi afo sen lac ita lno dae gni aot oll wtu mra nae hts bta zer enh owv dlu ven cre nuo net cna roe tua roh ezi cus mah ssi noi eve fin hew tda aeh ess ist lpn eca cot rra tiy tuo eht mem yro tfo ceh fno nor tat noi evo htr ime iss bel esa kni abu its bll nru nas htd ope iss lib yti nfo lcu rae nna ihi tal noi tsi soo ort tgn ujo its tyf sih ros fot tca noi dni dee eht lop bti oru sah ted mre eni htd tta reh eca sot cap sie teb ret uof thg nni rae rae oht ibr hwt ere ruo nwo cet onh gol ahy las aer pyd vor ide est tfl ebo pus ire tro feh sri ast let til nae htd ife tsr nam den aps fec gil sth rew cae moc ilp ehs ybd ruo reh seo bta kia uno uor mar ire nac moc dar mse hya eva oht hgu sut aew hwk wne ome dev ruo nul ora ibr ret eot usn ter seh efa oyt htf rie rif lts anu alr idn bgn ttu sih saw ena itn ler tsy tar ige omc iev etn edn otd iub cdl fno edi ecn teb eew uon wtr ano oit wsn tah liw htl dye ono htw tta tah eht rif lts anu alr idn hgn bsa nee cca pmo sil deh rom ale idn sgn woh nam omy rno kco acs htn pye sso lbi eny ade wdn tah liw til soc oft htr tme rbo gni eht ohm eem rev imy iss tno yeh ual hcn sir csk ata rts hpo fci lia eru dna won sti mee hts ota oen htf rie nwo wsi kro gni eot usn ter teh ato uhl lim tai noi tfo ceh ipa lat tsi sys met aem hwn eli ruo aog asl ber tte mre bte tsy vir gni lot rae rfn tmo aeh rem aci csn poo are nit hwg ere mew tsu eot usn ter tah wew wni reh ewe nac san daa nim tsi tar sro vah lae aer myd eda evo utr ser uot ocs ecn inr jgn nio xet olp tar noi dna ruo alp sin bot liu nod eht yrd ned alb nog var avo erg eme itn ewf nac ooc idr tan jae nio imt iss tno sih ohs dlu vig sue cca sse sot emo tfo aeh rem aci etn nhc aci nal rtd nia gni tam ire sla ihw oel oru rnw kco ste tsy sme era raf rom ose ihp its tac tde nah eht sri eht rri ile cna noe eht iks oll htf rie tsa nor tua ems sna aht htt hye eva ael enr afd omr aer uob htt ile tim fos muh ena udn nar aec pdn fre mro cna hte wna ahe bev nee lba ote fos ira iwt tll eka mos ite tem voo cre emo eht ema cir dna tsi sur fot ruo ats aet idn ast neg eic ubs sat nol sag eht ody ton leb vei hte wta rae ebe nih htd ere nec ast tob ega tta pme tst neh hti kni wew lli aeb elb aot ihc eve iht ogs al'" + ] + }, + "execution_count": 73, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "wcat(chunks(rcpb, 3))" + ] + }, + { + "cell_type": "code", + "execution_count": 71, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "to var ish chi our agents in the us have concluded their investigations and have determined that\n", + "there is indeed a saboteur working in the heart of the capitalist space agency security there has\n", + "tightened but they have been unable to discover who it is that is working to undermine their efforts\n", + "to colonise space no one in the kgb or gru is aware of anybody working directly for us who would or\n", + "could have carried out these attacks furthermore the risk of an escalation leading to all out war\n", + "means that brezhnev would never countenance or authorize such a mission even if we had the assets in\n", + "place to carry it out the memory of the confrontation over the missile base in kuba still burns and\n", + "the possibility of nuclear annihilation is too strong to justify this sort of action indeed the\n", + "politburo has determined that the race to space is better fought in near earth orbit where our own\n", + "technology has already proved itself to be superior the first satellite and the first manned space\n", + "flights were accomplished by our heroes at baikonur our american comrades may have thought us weak\n", + "when we moved our lunar orbiter to ensure the safety of their first lunar landing but this was an\n", + "entirely strategic move intended to build confidence between our two nations what will they do now\n", + "that that the first lunar landing has been accomplished more landing show many moon rocks can they\n", + "possibly need and what will it cost for them to bring them home every mission they launch risks\n", + "catastrophic failure and now it seems that one of their own is working to ensure the total\n", + "humiliation of the capitalist system meanwhile our goals are better met by striving to learn from\n", + "the americans cooperating where we must to ensure that we win where we can nasa administrators have\n", + "already made overtures to us concerning joint exploration and our plan is to build on the dryden\n", + "blag on ravo v agreement if we can coordinate a joint mission this should give us access to some of\n", + "the american technical and training materials while our own rocket systems are far more\n", + "sophisticated than theirs their reliance on the skill of their astronauts means that they have\n", + "learned far more about the limits of human endurance and performance than we have be enable to so\n", + "far it will take sometime to overcome the american distrust of our state and its agencies but as\n", + "long as they do not believe that we are behind the recent sabotage attempts then i think we will be\n", + "able to achieve this gola\n" + ] + } + ], + "source": [ + "print(lcat(tpack(segment(cat(cat(reversed(c)) for c in chunks(rcpb, 3))))))" + ] + }, + { + "cell_type": "code", + "execution_count": 72, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "2469" + ] + }, + "execution_count": 72, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "open(plaintext_b_filename, 'w').write(lcat(tpack(segment(cat(cat(reversed(c)) \n", + " for c in chunks(rcpb, 3))))))" + ] + }, + { + "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.5" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/2019/6a.ciphertext b/2019/6a.ciphertext new file mode 100644 index 0000000..b48d112 --- /dev/null +++ b/2019/6a.ciphertext @@ -0,0 +1,9 @@ +Yim flgf age jgzxgexoo audo! Zti rqxzqv za xnq Tuex iayrp lghi xqerxc yfmxdij flozky gt gzh vdibqrzurm uxy byhxmimxoar cmw g fsv bvoavofc. Ztetw cugv ldmkzhy ur Rmrmxie rsx sizfmts xnmx jark. + +Aj iayxei, zti rqxzqv xmmyqw gz ecryr xsz aj wgiyfmuzw gzh g iluxi tqa vdshxis. Ii taa nmzk fau urbqwzukgfmuzw gzh zis vqvvqxxmxudw za ggfgn: flk eehaxkgv gzh zti sapk. Flk xizfix ostfeozij pizmmre xnmx gdi qzscz xu m jki qkyfkdw ur sad xkmq gzh g iluxi hgrit sl qrmurkqvy mx TMWG es cq exq kuurm fs nmzk vyyf ey yyit xxayhxi tmvxaaozk zti tqa zmvmqx ruwz mw cq hop aofl zti luvyf stq, etp ak tebqr’z yejq qaol vdsmdiye aofl ztez. U waetkox ztez ayx xigwix imrx xxk xu siz tmy av nqv sqwymkk ayz mkgur, ya, vkxyifetfpe, U xnurq ii cupr tebq xu byz essq ilrsxf mtfs ztez urbqwzukgfmuz. M gy okqr tax za hohixf xua qaol xqwugviq ecmc ldss flk eehaxgsi kzuauve es imr O xighi eay xgrturm flk ysrq lazx? Eay gdi vdizfc cqpr ostziifij imzt xnq txqwy. U xnurq ii tqij fs zmok floe ecmc ldss flk OMG mw ztie mvk zsz digxpe eyvbsyqh za fk mgzuzk mx naqk, nyz yeeni eay iayrp idbpuux eayx axnqv rurqe ez flk Nyxqea? + +U hop lghi yaqk flugknfw gnsaf xnq pkfxkd: mz yeqqw g ossbirxmts ggei ztez flk Esbuize exq xu npgyi lav gxp zti vdshxise ez ZEYM, wu U wzqtvqh ab wadzkuprmriq mt flk GWYD, etp ey m vkeyrf xnq Xkgjkxwhqvm xmyfiturm bsyf mtfixoivfij flk mxzmgnqh sqwymkk ilool cmw lxemsij fsv eiidiz. Ii nmzk tej fvugfrq fxqequrm ux hgx uzi ur xnq joqpj mkkzxy flozoy ti xqgusroeiy ux ge e iaqhurgfmuz sl mrgsvgyqozk gzh ygfyfmzgxoar, ya qgkfk ii ytsaxh yqx g figy audoozk uz mz ar ztez neyuw. + +Zgvturm fs zti iarzqrz, ux xqeje e ruxzxi ruok m gxmde ostetodeik rkiwrqxzqv, gzh O mq lurjurm ux nmvj fs hqpoqzk mreark isxwmts ez flk mkkzge isaxh lux ztez bvurmrq. Faf ml ayx ysrq huqwt’f audo gf RGEE, ctixq exq xnqc mqxzurm mpr flkuv ozxkx jxaq? Cq exqr’z nvumhimwzurm ux gzh TMWG uw zdcozk bqve texp xu wikb mz grjqv cdeve. Gugpj ksa mwq flk Nyxqea’e txajoxixe xu feqq e rasq mrj eik uj ztie oet eik mreflozk? + +O wikb xnurqurm U lghi suwyqh yaqkflozk yuktujooetf lkdi, gzh ztixq age hkrmtuxkxc yaqkflozk oz cugv rmwz yiyeemq xnmx oe vkmprk fuflkdmts qk, nyz U ggz’x vgx sk jozkkd st ux. O mq ygvk flkdi oe e huk ixyk fs yaqkflozk yfexurm yi oz xnq jgoi. O’xp rqx eay qzsc uj O isxw mz ayz. Ur zti sqetfmsq, lkdi oe xnq mtfixoivf, pkf qk wrui lui cug kkf st. diff --git a/2019/6a.plaintext b/2019/6a.plaintext new file mode 100644 index 0000000..54b036c --- /dev/null +++ b/2019/6a.plaintext @@ -0,0 +1,9 @@ +Meg that was fantastic work! The letter to the Post could have really stirred things up and preventing its publication was a top priority. Thank your friends in Langley for getting that done. + +Of course, the letter raises an awful lot of questions and a whole new problem. We now have two investigations and two perpetrators to catch: the saboteur and the mole. The letter contained details that are known to a few members of our team and a whole bunch of engineers at NASA so we are going to have just as much trouble narrowing the new target list as we did with the first one, and we haven’t made much progress with that. I suspect that our leaker will try to get his or her message out again, so, reluctantly, I think we will have to put some effort into that investigation. I am keen not to divert too much resource away from the sabotage enquiry so can I leave you running the mole hunt? You are pretty well connected with the press. I think we need to take this away from the CIA as they are not really supposed to be active at home, but maybe you could exploit your other links at the Bureau? + +I did have some thoughts about the letter: it makes a compelling case that the Soviets are to blame for all the problems at NASA, so I stepped up surveillance in the USSR, and as a result the Teufelsberg listening post intercepted the attached message which was flagged top secret. We have had trouble breaking it but one of the field agents thinks he recognises it as a combination of anagramming and substitution, so maybe we should set a team working on it on that basis. + +Turning to the content, it reads a little like a crazy conspiracy newsletter, and I am finding it hard to believe anyone working at the agency would fit that profile. But if our mole doesn’t work at NASA, where are they getting all their intel from? We aren’t broadcasting it and NASA is trying very hard to keep it under wraps. Could you ask the Bureau’s profilers to take a look and see if they can see anything? + +I keep thinking I have missed something significant here, and there was definitely something in your last message that is really bothering me, but I can’t put my finger on it. I am sure there is a big clue to something staring me in the face. I’ll let you know if I work it out. In the meantime, here is the intercept, let me know how you get on. diff --git a/2019/6b.ciphertext b/2019/6b.ciphertext new file mode 100644 index 0000000..ffac470 --- /dev/null +++ b/2019/6b.ciphertext @@ -0,0 +1 @@ +WKQCN TVHPK CHTNU JRSCP QHQJP URWTH KVRFV JRAUH QANCR WJCQP RTSCK CQTPJ HAJRW TQRAG NRRJC HQAQQ TNRHP CRAJC ARRTP TQKON URNKX JCEJC SRHQT RHKQN HQITV RQCLC FTPQP VTLST RVJRR PZNUV ZQCRH QHRNQ PTHSC JRQOA RQQUZ RHWTH RORUJ ROTJQ RFCAK KVPNR WKHXC QCHQP CQTKX PCENQ SJJUK NRAJC GHQRN CRIIR QNKKQ PFKVC JKPRP VTLKJ RRJKQ JCERH KOSNS NPCUT XTKRN JTIKO ZXZAE NKSJC NCAQV RIZFU NKHXP KXKAF UVNKF UKTHA VRWNN TARCQ UKRHQ TRPTQ QPEVN UIRHQ KGNQR NNRHE PCTIK PRJFT VCQTF JKATR SJCTK QKFFX QUGNT JTRHQ POQTB RNRJH KXWAF UWRJV NRJUK JRQVJ TNKRQ UTNKH RBCVU PGTHP PCJKC RWRIC JHRXQ ATTRH RPPCP QFLJR VTVKQ NNTQC ZQUKR HQGRG ZNKQI KVRHI JKJKN QTQJK CRWKH QNCGR CPPOR FRPTE JCTOU CQPOF FJNUJ TPHQA KLRCP PFCOZ QCJIK FVUNT RJJTC HCQTF JKCQP CPKKK NQQSJ UDKCQ PQZIP CHNKP IKQQV TJKCA JCARR RHQFK LOQCK NUPTH QRAGN RRJCH QAQQT NRHRV TPKQV TLPCR QRONR QUKIQ HSJJC NTRNT RKHQC ONHXQ RNRNU KJXKV RQKJH SKFTH ZFTPT RNLZA WKNCA RRPQQ IFROK LUPCN RQNKI RHPNC TPQFR QQCFJ TRHQA CIRQP NJTGA RJTLP IRVSC FPQHN RXVTR GKVCF LRHPZ OANUK NRHPR KOQTE CTUJK UKNGT NCNRJ TVGKV ATNGP RHZTR WTKHQ HSUPU QTRXH XEXJR KGRAR WNUKJ UFKNT CONNR QRKQU PJQRN PRHRI TKZQH QINCR NCIFQ PTJUT FNCAJ OSJQQ UPCHP TXRJT CQJFR NQPZQ TNCSR KGVCR WRQJR AJKQA CUOVA FIJKR ACRVJ QRORR XUKJX QNTJK KCQXP JQTHF CXHQF AZRKJ KHQXQ QTQTH RHQNC IFQPT JUTFN CAJHS JOPTJ RRVVT LGKPC FARHN KGTFR CAJPS JXKHJ TGKGZ NJKEV KTVPH QJLZR PPKFO CRJZT ARXAJ QTHFC XQCFP KVKIQ HQNQG RNOKS JCRHQ KHGRR GNRWC GZCPP QJKZR HUTFH VJPCN VPETQ TNQPH LKIVC FCTRN UAJTX KJPQC GRRHQ PKQTK RJHQI NCRJX KXPCE NKSJC RKQUP JQRNQ RHTQK UHFFC GQTCJ KCQIK VRHCL TFTQQ PCPZP GRQTR GHXJR FCNUK TKSTP FORNQ QRGNR OQRQP ZWCNS JCFKQ NTRNI JQGKT RHNRG TVCVP JLKKT NRJCQ HXSRN RGRXQ PURKQ UPJQR NQTHX RXXJC NRHRX RJTVP TJATT JCGQP CQTNP NKWTH FTRTR NGZAR ATRWK UQNPR NUKQK VPRVJ CJNDS JJCKY RQKFL QTNJK CAJTN UKTFL PCJOK QFCUJ KARHQ ZNAJR ATFOJ KSWTN TWKRN SRGRC QJRXI JTVKK VCANQ TJDTR JCKCG QCPPQ JKPCH KHPAF UWCSP URVVT PPRPK QRGKQ IKTRH NRGTV CRQJJ HVTVC JTFNQ AJCTS JCQTG CNRPF TCHXK RFKNU NJXEV KPQRQ PZPGR RNTNT INKGK PRCHL CQPQT VQARJ THRHQ PNCRH QNNCC FRVJT JKRRH QCEPK FFHQI NCRQP TJKNQ UTRGP PJTTH QHQQH ZRRWT TRFRJ NTIAK GNTRN UKOHQ QCFRQ CGIKP GUHRJ TUAJJ TNTRV LAJIN RGNKV JTHQR XJTTH RORWJ RRFOT KQRIK PCNTC XQQFF RETGK PCQRQ RGWKK VNRRG KRHQR GTVCN AJTQP CPUNI KQNUK TQPTR QCAJT PQJRS RCVUO PPTQJ KFPTS RHQKA ZQKJF ROWRC HQRXQ TNTRR ORJCH HQARN RJRVT PQQKO RSTQQ TLGRQ PQJRH HQCEJ CXRXF FCTRO RFOTK QCHVR WRCHQ KSPTF diff --git a/2019/6b.plaintext b/2019/6b.plaintext new file mode 100644 index 0000000..da10c30 --- /dev/null +++ b/2019/6b.plaintext @@ -0,0 +1,26 @@ +to var ish chi our agents in the us have concluded their investigations and have determined that +there is indeed a saboteur working in the heart of the capitalist space agency security there has +tightened but they have been unable to discover who it is that is working to undermine their efforts +to colonise space no one in the kgb or gru is aware of anybody working directly for us who would or +could have carried out these attacks furthermore the risk of an escalation leading to all out war +means that brezhnev would never countenance or authorize such a mission even if we had the assets in +place to carry it out the memory of the confrontation over the missile base in kuba still burns and +the possibility of nuclear annihilation is too strong to justify this sort of action indeed the +politburo has determined that the race to space is better fought in near earth orbit where our own +technology has already proved itself to be superior the first satellite and the first manned space +flights were accomplished by our heroes at baikonur our american comrades may have thought us weak +when we moved our lunar orbiter to ensure the safety of their first lunar landing but this was an +entirely strategic move intended to build confidence between our two nations what will they do now +that that the first lunar landing has been accomplished more landing show many moon rocks can they +possibly need and what will it cost for them to bring them home every mission they launch risks +catastrophic failure and now it seems that one of their own is working to ensure the total +humiliation of the capitalist system meanwhile our goals are better met by striving to learn from +the americans cooperating where we must to ensure that we win where we can nasa administrators have +already made overtures to us concerning joint exploration and our plan is to build on the dryden +blag on ravo v agreement if we can coordinate a joint mission this should give us access to some of +the american technical and training materials while our own rocket systems are far more +sophisticated than theirs their reliance on the skill of their astronauts means that they have +learned far more about the limits of human endurance and performance than we have be enable to so +far it will take sometime to overcome the american distrust of our state and its agencies but as +long as they do not believe that we are behind the recent sabotage attempts then i think we will be +able to achieve this gola \ No newline at end of file