[{"data":1,"prerenderedAt":669},["ShallowReactive",2],{"navigation_docs":3,"-ciphers-two-square":308,"-ciphers-two-square-surround":664},[4,36],{"title":5,"path":6,"stem":7,"children":8,"icon":35},"Guide","\u002Fguide","1.guide\u002F01.index",[9,11,15,19,23,27,31],{"title":10,"path":6,"stem":7},"Getting Started",{"title":12,"path":13,"stem":14},"Encode and decode","\u002Fguide\u002Ftransform","1.guide\u002F02.transform",{"title":16,"path":17,"stem":18},"Analysis","\u002Fguide\u002Fanalysis","1.guide\u002F03.analysis",{"title":20,"path":21,"stem":22},"CLI","\u002Fguide\u002Fcli","1.guide\u002F04.cli",{"title":24,"path":25,"stem":26},"Agents","\u002Fguide\u002Fagents","1.guide\u002F05.agents",{"title":28,"path":29,"stem":30},"Custom ciphers","\u002Fguide\u002Fcustom","1.guide\u002F06.custom",{"title":32,"path":33,"stem":34},"Playground","\u002Fguide\u002Fplayground","1.guide\u002F07.playground","i-lucide-book-open",{"title":37,"path":38,"stem":39,"children":40,"icon":307},"Ciphers","\u002Fciphers","2.ciphers\u002F00.index",[41,43,47,51,55,59,63,67,71,75,79,83,87,91,95,99,103,107,111,115,119,123,127,131,135,139,143,147,151,155,159,163,167,171,175,179,183,187,191,195,199,203,207,211,215,219,223,227,231,235,239,243,247,251,255,259,263,267,271,275,279,283,287,291,295,299,303],{"title":42,"path":38,"stem":39},"Overview",{"title":44,"path":45,"stem":46},"Classical","\u002Fciphers\u002Fclassical","2.ciphers\u002F01.classical",{"title":48,"path":49,"stem":50},"Caesar","\u002Fciphers\u002Fcaesar","2.ciphers\u002F02.caesar",{"title":52,"path":53,"stem":54},"ROT-13","\u002Fciphers\u002Frot13","2.ciphers\u002F03.rot13",{"title":56,"path":57,"stem":58},"ROT-47","\u002Fciphers\u002Frot47","2.ciphers\u002F04.rot47",{"title":60,"path":61,"stem":62},"Atbash","\u002Fciphers\u002Fatbash","2.ciphers\u002F05.atbash",{"title":64,"path":65,"stem":66},"Affine","\u002Fciphers\u002Faffine","2.ciphers\u002F06.affine",{"title":68,"path":69,"stem":70},"Substitution","\u002Fciphers\u002Fsubstitution","2.ciphers\u002F07.substitution",{"title":72,"path":73,"stem":74},"Vigenère","\u002Fciphers\u002Fvigenere","2.ciphers\u002F08.vigenere",{"title":76,"path":77,"stem":78},"Gronsfeld","\u002Fciphers\u002Fgronsfeld","2.ciphers\u002F09.gronsfeld",{"title":80,"path":81,"stem":82},"Beaufort","\u002Fciphers\u002Fbeaufort","2.ciphers\u002F10.beaufort",{"title":84,"path":85,"stem":86},"Porta","\u002Fciphers\u002Fporta","2.ciphers\u002F11.porta",{"title":88,"path":89,"stem":90},"Autokey","\u002Fciphers\u002Fautokey","2.ciphers\u002F12.autokey",{"title":92,"path":93,"stem":94},"Running key","\u002Fciphers\u002Frunning-key","2.ciphers\u002F13.running-key",{"title":96,"path":97,"stem":98},"Trithemius","\u002Fciphers\u002Ftrithemius","2.ciphers\u002F14.trithemius",{"title":100,"path":101,"stem":102},"Alberti","\u002Fciphers\u002Falberti","2.ciphers\u002F15.alberti",{"title":104,"path":105,"stem":106},"Playfair","\u002Fciphers\u002Fplayfair","2.ciphers\u002F16.playfair",{"title":108,"path":109,"stem":110},"Four-square","\u002Fciphers\u002Ffour-square","2.ciphers\u002F17.four-square",{"title":112,"path":113,"stem":114},"Two-square","\u002Fciphers\u002Ftwo-square","2.ciphers\u002F18.two-square",{"title":116,"path":117,"stem":118},"Hill","\u002Fciphers\u002Fhill","2.ciphers\u002F19.hill",{"title":120,"path":121,"stem":122},"Polybius square","\u002Fciphers\u002Fpolybius","2.ciphers\u002F20.polybius",{"title":124,"path":125,"stem":126},"Nihilist","\u002Fciphers\u002Fnihilist","2.ciphers\u002F21.nihilist",{"title":128,"path":129,"stem":130},"Morse code","\u002Fciphers\u002Fmorse","2.ciphers\u002F22.morse",{"title":132,"path":133,"stem":134},"Bacon's cipher","\u002Fciphers\u002Fbacon","2.ciphers\u002F23.bacon",{"title":136,"path":137,"stem":138},"Tap code","\u002Fciphers\u002Ftap-code","2.ciphers\u002F24.tap-code",{"title":140,"path":141,"stem":142},"A1Z26","\u002Fciphers\u002Fa1z26","2.ciphers\u002F25.a1z26",{"title":144,"path":145,"stem":146},"Book cipher","\u002Fciphers\u002Fbook","2.ciphers\u002F26.book",{"title":148,"path":149,"stem":150},"ADFGVX","\u002Fciphers\u002Fadfgvx","2.ciphers\u002F27.adfgvx",{"title":152,"path":153,"stem":154},"Bifid","\u002Fciphers\u002Fbifid","2.ciphers\u002F28.bifid",{"title":156,"path":157,"stem":158},"Straddling checkerboard","\u002Fciphers\u002Fstraddling-checkerboard","2.ciphers\u002F29.straddling-checkerboard",{"title":160,"path":161,"stem":162},"Rail fence","\u002Fciphers\u002Frail-fence","2.ciphers\u002F30.rail-fence",{"title":164,"path":165,"stem":166},"Columnar transposition","\u002Fciphers\u002Fcolumnar","2.ciphers\u002F31.columnar",{"title":168,"path":169,"stem":170},"Route transposition","\u002Fciphers\u002Froute","2.ciphers\u002F32.route",{"title":172,"path":173,"stem":174},"Enigma M3","\u002Fciphers\u002Fenigma","2.ciphers\u002F33.enigma",{"title":176,"path":177,"stem":178},"Block","\u002Fciphers\u002Fblock","2.ciphers\u002F34.block",{"title":180,"path":181,"stem":182},"AES (ECB)","\u002Fciphers\u002Faes","2.ciphers\u002F35.aes",{"title":184,"path":185,"stem":186},"AES (CBC)","\u002Fciphers\u002Faes-cbc","2.ciphers\u002F36.aes-cbc",{"title":188,"path":189,"stem":190},"AES (CFB)","\u002Fciphers\u002Faes-cfb","2.ciphers\u002F37.aes-cfb",{"title":192,"path":193,"stem":194},"AES (OFB)","\u002Fciphers\u002Faes-ofb","2.ciphers\u002F38.aes-ofb",{"title":196,"path":197,"stem":198},"AES (CTR)","\u002Fciphers\u002Faes-ctr","2.ciphers\u002F39.aes-ctr",{"title":200,"path":201,"stem":202},"AES (CCM)","\u002Fciphers\u002Faes-ccm","2.ciphers\u002F40.aes-ccm",{"title":204,"path":205,"stem":206},"AES (OCB)","\u002Fciphers\u002Faes-ocb","2.ciphers\u002F41.aes-ocb",{"title":208,"path":209,"stem":210},"AES (LRW)","\u002Fciphers\u002Faes-lrw","2.ciphers\u002F42.aes-lrw",{"title":212,"path":213,"stem":214},"AES (XTS)","\u002Fciphers\u002Faes-xts","2.ciphers\u002F43.aes-xts",{"title":216,"path":217,"stem":218},"AES (CBC-MAC)","\u002Fciphers\u002Faes-cbc-mac","2.ciphers\u002F44.aes-cbc-mac",{"title":220,"path":221,"stem":222},"AES (passphrase)","\u002Fciphers\u002Faes-passphrase","2.ciphers\u002F45.aes-passphrase",{"title":224,"path":225,"stem":226},"Rijndael (ECB)","\u002Fciphers\u002Frijndael","2.ciphers\u002F46.rijndael",{"title":228,"path":229,"stem":230},"DES (ECB)","\u002Fciphers\u002Fdes","2.ciphers\u002F47.des",{"title":232,"path":233,"stem":234},"DESX (ECB)","\u002Fciphers\u002Fdesx","2.ciphers\u002F48.desx",{"title":236,"path":237,"stem":238},"Triple DES (ECB)","\u002Fciphers\u002Ftriple-des","2.ciphers\u002F49.triple-des",{"title":240,"path":241,"stem":242},"Triple DES (CBC)","\u002Fciphers\u002Ftriple-des-cbc","2.ciphers\u002F50.triple-des-cbc",{"title":244,"path":245,"stem":246},"Blowfish (ECB)","\u002Fciphers\u002Fblowfish","2.ciphers\u002F51.blowfish",{"title":248,"path":249,"stem":250},"IDEA (ECB)","\u002Fciphers\u002Fidea","2.ciphers\u002F52.idea",{"title":252,"path":253,"stem":254},"Lucifer (ECB)","\u002Fciphers\u002Flucifer","2.ciphers\u002F53.lucifer",{"title":256,"path":257,"stem":258},"MARS (ECB)","\u002Fciphers\u002Fmars","2.ciphers\u002F54.mars",{"title":260,"path":261,"stem":262},"Serpent (ECB)","\u002Fciphers\u002Fserpent","2.ciphers\u002F55.serpent",{"title":264,"path":265,"stem":266},"CAST5 (ECB)","\u002Fciphers\u002Fcast5","2.ciphers\u002F56.cast5",{"title":268,"path":269,"stem":270},"OpenPGP (passphrase)","\u002Fciphers\u002Fopenpgp","2.ciphers\u002F57.openpgp",{"title":272,"path":273,"stem":274},"Stream","\u002Fciphers\u002Fstream","2.ciphers\u002F58.stream",{"title":276,"path":277,"stem":278},"Rabbit","\u002Fciphers\u002Frabbit","2.ciphers\u002F59.rabbit",{"title":280,"path":281,"stem":282},"RC4","\u002Fciphers\u002Frc4","2.ciphers\u002F60.rc4",{"title":284,"path":285,"stem":286},"XOR","\u002Fciphers\u002Fxor","2.ciphers\u002F61.xor",{"title":288,"path":289,"stem":290},"Salsa20","\u002Fciphers\u002Fsalsa20","2.ciphers\u002F62.salsa20",{"title":292,"path":293,"stem":294},"XSalsa20","\u002Fciphers\u002Fxsalsa20","2.ciphers\u002F63.xsalsa20",{"title":296,"path":297,"stem":298},"ChaCha20","\u002Fciphers\u002Fchacha20","2.ciphers\u002F64.chacha20",{"title":300,"path":301,"stem":302},"XChaCha20","\u002Fciphers\u002Fxchacha20","2.ciphers\u002F65.xchacha20",{"title":304,"path":305,"stem":306},"ChaCha20-Poly1305","\u002Fciphers\u002Fchacha20-poly1305","2.ciphers\u002F66.chacha20-poly1305","i-lucide-library",{"id":309,"title":112,"body":310,"description":657,"extension":658,"links":659,"meta":660,"navigation":661,"path":113,"seo":662,"stem":114,"__hash__":663},"docs\u002F2.ciphers\u002F18.two-square.md",{"type":311,"value":312,"toc":651},"minimark",[313,317,321,431,453,458,469,472,476,488,539,577,583,590,594,612,619,623,632,638,647],[314,315],"cipher-facts",{"name":316},"two-square",[318,319,320],"p",{},"Four-square with the plain squares thrown out. Delastelle put it in the same book and called it a reduced digraphic checkerboard, which is a very French way to say \"two squares\". Find the first letter of a pair in one square, the second in the other. The rectangle they span gives the ciphertext. Half the drawing, and a leak to match.",[322,323,328],"pre",{"className":324,"code":325,"language":326,"meta":327,"style":327},"language-ts shiki shiki-themes ciphers ciphers ciphers","const twoSquare = create(\"two-square\");\nconst keys = { key: \"EXAMPLE\", secondKey: \"KEYWORD\", omit: \"q\" };\ntwoSquare.encode(\"help me obi wan kenobi\", keys).text; \u002F\u002F \"HEDLXWSDJYANHOTKDG\"\ntwoSquare.decode(\"HEDLXWSDJYANHOTKDG\", keys).text; \u002F\u002F \"HELPMEOBIWANKENOBI\"\n","ts","",[329,330,331,361,392,413],"code",{"__ignoreMap":327},[332,333,336,340,344,347,351,354,358],"span",{"class":334,"line":335},"line",1,[332,337,339],{"class":338},"skH_V","const",[332,341,343],{"class":342},"s38Sx"," twoSquare ",[332,345,346],{"class":338},"=",[332,348,350],{"class":349},"sK71F"," create",[332,352,353],{"class":342},"(",[332,355,357],{"class":356},"shU9J","\"two-square\"",[332,359,360],{"class":342},");\n",[332,362,364,366,369,371,374,377,380,383,386,389],{"class":334,"line":363},2,[332,365,339],{"class":338},[332,367,368],{"class":342}," keys ",[332,370,346],{"class":338},[332,372,373],{"class":342}," { key: ",[332,375,376],{"class":356},"\"EXAMPLE\"",[332,378,379],{"class":342},", secondKey: ",[332,381,382],{"class":356},"\"KEYWORD\"",[332,384,385],{"class":342},", omit: ",[332,387,388],{"class":356},"\"q\"",[332,390,391],{"class":342}," };\n",[332,393,395,398,401,403,406,409],{"class":334,"line":394},3,[332,396,397],{"class":342},"twoSquare.",[332,399,400],{"class":349},"encode",[332,402,353],{"class":342},[332,404,405],{"class":356},"\"help me obi wan kenobi\"",[332,407,408],{"class":342},", keys).text; ",[332,410,412],{"class":411},"scIB-","\u002F\u002F \"HEDLXWSDJYANHOTKDG\"\n",[332,414,416,418,421,423,426,428],{"class":334,"line":415},4,[332,417,397],{"class":342},[332,419,420],{"class":349},"decode",[332,422,353],{"class":342},[332,424,425],{"class":356},"\"HEDLXWSDJYANHOTKDG\"",[332,427,408],{"class":342},[332,429,430],{"class":411},"\u002F\u002F \"HELPMEOBIWANKENOBI\"\n",[318,432,433,434,441,442,445,446,448,449,452],{},"That's the ",[435,436,440],"a",{"href":437,"rel":438},"https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FTwo-square_cipher",[439],"nofollow","example on Wikipedia",". Look at the first pair. ",[329,443,444],{},"HE"," went in, ",[329,447,444],{}," came out. ",[329,450,451],{},"AN"," too. Not a bug, that's the cipher.",[454,455,457],"h2",{"id":456},"why-do-pairs-slip-through","Why do pairs slip through?",[318,459,460,461,464,465,468],{},"By default the squares are stacked, ",[329,462,463],{},"key"," on top and ",[329,466,467],{},"secondKey"," below. Each letter comes back from its own square, on its own row, in the other letter's column. Now put both letters in one column. The other letter's column is the same one, so nothing moves. Random squares do that to about one pair in five.",[318,470,471],{},"Decoding is the same step here. Encode the ciphertext again and you get the plaintext back.",[454,473,475],{"id":474},"side-by-side","Side by side",[318,477,478,481,482,484,485,487],{},[329,479,480],{},"orientation: \"horizontal\""," puts ",[329,483,463],{}," on the left and ",[329,486,467],{}," on the right. The ACA prints it that way, and dCode starts there too. The rectangle now crosses from one square into the other, so each letter's partner lives in the other square. A pair in one row comes out reversed.",[322,489,491],{"className":324,"code":490,"language":326,"meta":327,"style":327},"const aca = { key: \"DIALOGUE\", secondKey: \"BIOGRAPHY\", orientation: \"horizontal\" };\ntwoSquare.encode(\"another digraphic setup\", aca).text;\n\u002F\u002F \"IRRTEHMKGIMEQGRUNMMZSV\"\n",[329,492,493,520,534],{"__ignoreMap":327},[332,494,495,497,500,502,504,507,509,512,515,518],{"class":334,"line":335},[332,496,339],{"class":338},[332,498,499],{"class":342}," aca ",[332,501,346],{"class":338},[332,503,373],{"class":342},[332,505,506],{"class":356},"\"DIALOGUE\"",[332,508,379],{"class":342},[332,510,511],{"class":356},"\"BIOGRAPHY\"",[332,513,514],{"class":342},", orientation: ",[332,516,517],{"class":356},"\"horizontal\"",[332,519,391],{"class":342},[332,521,522,524,526,528,531],{"class":334,"line":363},[332,523,397],{"class":342},[332,525,400],{"class":349},[332,527,353],{"class":342},[332,529,530],{"class":356},"\"another digraphic setup\"",[332,532,533],{"class":342},", aca).text;\n",[332,535,536],{"class":334,"line":394},[332,537,538],{"class":411},"\u002F\u002F \"IRRTEHMKGIMEQGRUNMMZSV\"\n",[318,540,433,541,546,547,550,551,554,555,560,561,564,565,568,569,572,573,576],{},[435,542,545],{"href":543,"rel":544},"https:\u002F\u002Fwww.cryptogram.org\u002Fdownloads\u002Faca.info\u002Fciphers\u002FTwoSquare.pdf",[439],"ACA's own example",". See the ",[329,548,549],{},"EH"," in the middle? It's ",[329,552,553],{},"he",", read backwards. The ",[435,556,559],{"href":557,"rel":558},"https:\u002F\u002Fwww.dcode.fr\u002Ftwo-square-cipher",[439],"dCode one"," works the same way: ",[329,562,563],{},"CDLBAV"," under ",[329,566,567],{},"KEY"," and ",[329,570,571],{},"WORD"," decodes to ",[329,574,575],{},"DCODEZ",".",[318,578,579,580,582],{},"Side by side, decoding isn't encoding anymore. Run ",[329,581,400],{}," twice and you get mush. So say which way you're going.",[318,584,585,586,589],{},"Crypto Corner sets its squares side by side too, but trades rows where the ACA and dCode trade columns. Its horizontal ciphertext won't match, and no option here bends to it. Its stacked one does: ",[329,587,588],{},"HECMXWSRKYXPHWNODG",", with I and J sharing a cell.",[454,591,593],{"id":592},"j-or-q","J or Q?",[318,595,596,597,600,601,604,605,568,608,611],{},"Same deal as ",[435,598,599],{"href":109},"four-square",". J folds into I by default. ",[329,602,603],{},"omit: \"q\""," drops Q from the squares, the keywords and the text, which is what the Wikipedia example needs. The result options carry ",[329,606,607],{},"orientation",[329,609,610],{},"omit"," only when they aren't the default.",[318,613,614,615,618],{},"The text loses everything but letters and comes out in capitals. An odd length gets an X, and a doubled pair stays doubled. Ciphertext with an odd number of letters is a ",[329,616,617],{},"CipherError",". Both keywords are required, and each needs at least one ASCII letter.",[454,620,622],{"id":621},"spotting-one","Spotting one",[318,624,625,626,631],{},"From a distance it's four-square. Even count, no J, doubled pairs allowed. Up close, some pairs read like English. ",[435,627,628],{"href":17},[329,629,630],{},"guess"," scores the pairs at even positions against English, straight and reversed. When they read better than a four-square leaves them, two-square moves ahead and the signal names the layout.",[318,633,634,635,637],{},"How good is that? Honestly, meh. At 100 letters it catches about half of them, at 400 about seven in ten. A four-square fools it about one time in eight. Only English has a pair table, and squares without Q put J back in the text, so ",[329,636,630],{}," misses those.",[318,639,640,641,568,644,646],{},"Want to do it by hand? Write the ciphertext in pairs and just read. ",[329,642,643],{},"TH",[329,645,444],{}," sitting on pair boundaries are a two-square getting lazy. Nothing there? Flip every pair and read again.",[648,649,650],"style",{},"html pre.shiki code .skH_V, html code.shiki .skH_V{--shiki-light:var(--shiki-token-keyword);--shiki-default:var(--shiki-token-keyword);--shiki-dark:var(--shiki-token-keyword)}html pre.shiki code .s38Sx, html code.shiki .s38Sx{--shiki-light:var(--ui-text-highlighted);--shiki-default:var(--ui-text-highlighted);--shiki-dark:var(--ui-text-highlighted)}html pre.shiki code .sK71F, html code.shiki .sK71F{--shiki-light:var(--shiki-token-function);--shiki-default:var(--shiki-token-function);--shiki-dark:var(--shiki-token-function)}html pre.shiki code .shU9J, html code.shiki .shU9J{--shiki-light:var(--shiki-token-string);--shiki-default:var(--shiki-token-string);--shiki-dark:var(--shiki-token-string)}html pre.shiki code .scIB-, html code.shiki .scIB-{--shiki-light:var(--shiki-token-comment);--shiki-default:var(--shiki-token-comment);--shiki-dark:var(--shiki-token-comment)}html .light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html.light .shiki span {color: var(--shiki-light);background: var(--shiki-light-bg);font-style: var(--shiki-light-font-style);font-weight: var(--shiki-light-font-weight);text-decoration: var(--shiki-light-text-decoration);}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":327,"searchDepth":363,"depth":363,"links":652},[653,654,655,656],{"id":456,"depth":363,"text":457},{"id":474,"depth":363,"text":475},{"id":592,"depth":363,"text":593},{"id":621,"depth":363,"text":622},"Delastelle's two keyed 5×5 squares, stacked or side by side. About one letter pair in five slips through in plain sight, and that's the fun part.","md",null,{},true,{"title":112,"description":657},"cfixVkF747i2HJSBOO-91XNZOmNGewXm0XVSAb6oRSo",[665,667],{"title":108,"path":109,"stem":110,"description":666,"children":-1},"Delastelle's four 5×5 squares, two plain and two keyed. Letter pairs go across the corners, and doubled letters come out the other side.",{"title":116,"path":117,"stem":118,"description":668,"children":-1},"Blocks of two or three letters go through a key matrix mod 26. Linear algebra in a puzzle. Nobody asked for it.",1791464490400]