--- /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 *\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', <KeywordWrapAlphabet.from_last: 2>, -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', <KeywordWrapAlphabet.from_last: 2>), -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
+}