[{"data":1,"prerenderedAt":473},["ShallowReactive",2],{"navigation_docs":3,"-ciphers-aes":148,"-ciphers-aes-surround":468},[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-solar-book-2-linear",{"title":37,"path":38,"stem":39,"children":40,"icon":147},"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],{"title":42,"path":38,"stem":39},"Overview",{"title":44,"path":45,"stem":46},"Caesar","\u002Fciphers\u002Fcaesar","2.ciphers\u002F01.caesar",{"title":48,"path":49,"stem":50},"ROT-13","\u002Fciphers\u002Frot13","2.ciphers\u002F02.rot13",{"title":52,"path":53,"stem":54},"ROT-47","\u002Fciphers\u002Frot47","2.ciphers\u002F03.rot47",{"title":56,"path":57,"stem":58},"Atbash","\u002Fciphers\u002Fatbash","2.ciphers\u002F04.atbash",{"title":60,"path":61,"stem":62},"Affine","\u002Fciphers\u002Faffine","2.ciphers\u002F05.affine",{"title":64,"path":65,"stem":66},"Vigenère","\u002Fciphers\u002Fvigenere","2.ciphers\u002F06.vigenere",{"title":68,"path":69,"stem":70},"Trithemius","\u002Fciphers\u002Ftrithemius","2.ciphers\u002F07.trithemius",{"title":72,"path":73,"stem":74},"Alberti","\u002Fciphers\u002Falberti","2.ciphers\u002F08.alberti",{"title":76,"path":77,"stem":78},"Playfair","\u002Fciphers\u002Fplayfair","2.ciphers\u002F09.playfair",{"title":80,"path":81,"stem":82},"Polybius square","\u002Fciphers\u002Fpolybius","2.ciphers\u002F10.polybius",{"title":84,"path":85,"stem":86},"Morse code","\u002Fciphers\u002Fmorse","2.ciphers\u002F11.morse",{"title":88,"path":89,"stem":90},"Bacon's cipher","\u002Fciphers\u002Fbacon","2.ciphers\u002F12.bacon",{"title":92,"path":93,"stem":94},"Tap code","\u002Fciphers\u002Ftap-code","2.ciphers\u002F13.tap-code",{"title":96,"path":97,"stem":98},"ADFGVX","\u002Fciphers\u002Fadfgvx","2.ciphers\u002F14.adfgvx",{"title":100,"path":101,"stem":102},"Bifid","\u002Fciphers\u002Fbifid","2.ciphers\u002F15.bifid",{"title":104,"path":105,"stem":106},"Rail fence","\u002Fciphers\u002Frail-fence","2.ciphers\u002F16.rail-fence",{"title":108,"path":109,"stem":110},"Columnar transposition","\u002Fciphers\u002Fcolumnar","2.ciphers\u002F17.columnar",{"title":112,"path":113,"stem":114},"Enigma M3","\u002Fciphers\u002Fenigma","2.ciphers\u002F18.enigma",{"title":116,"path":117,"stem":118},"Beaufort","\u002Fciphers\u002Fbeaufort","2.ciphers\u002F19.beaufort",{"title":120,"path":121,"stem":122},"Autokey","\u002Fciphers\u002Fautokey","2.ciphers\u002F20.autokey",{"title":124,"path":125,"stem":126},"AES (ECB)","\u002Fciphers\u002Faes","2.ciphers\u002F21.aes",{"title":128,"path":129,"stem":130},"Triple DES (ECB)","\u002Fciphers\u002Ftriple-des","2.ciphers\u002F22.triple-des",{"title":132,"path":133,"stem":134},"AES (LRW)","\u002Fciphers\u002Faes-lrw","2.ciphers\u002F23.aes-lrw",{"title":136,"path":137,"stem":138},"AES (CBC)","\u002Fciphers\u002Faes-cbc","2.ciphers\u002F24.aes-cbc",{"title":140,"path":141,"stem":142},"AES (CFB)","\u002Fciphers\u002Faes-cfb","2.ciphers\u002F25.aes-cfb",{"title":144,"path":145,"stem":146},"AES (CTR)","\u002Fciphers\u002Faes-ctr","2.ciphers\u002F26.aes-ctr","i-solar-library-linear",{"id":149,"title":124,"body":150,"description":461,"extension":462,"links":463,"meta":464,"navigation":465,"path":125,"seo":466,"stem":126,"__hash__":467},"docs\u002F2.ciphers\u002F21.aes.md",{"type":151,"value":152,"toc":458},"minimark",[153,157,166,302,305,356,359,364,371,430,433,451,454],[154,155],"cipher-facts",{"name":156},"aes",[158,159,160,161,165],"p",{},"AES from FIPS-197 with a 128, 192 or 256-bit key, picked by the key length: 32, 48 or 64 hex digits. Case doesn't matter and spaces are ignored. The mode is ECB, the electronic codebook. The text is encoded as UTF-8 and padded with PKCS#7, then each 16-byte block is encrypted with the same key and nothing else. The ciphertext comes back as lowercase hex, and ",[162,163,164],"code",{},"decode"," wants hex too.",[167,168,173],"pre",{"className":169,"code":170,"language":171,"meta":172,"style":172},"language-ts shiki shiki-themes github-light github-light poimandres","const aes = create(\"aes\");\nconst key = \"2b7e151628aed2a6abf7158809cf4f3c\";\naes.encode(\"ATTACK AT DAWN\", { key }).text; \u002F\u002F \"bef12e48d0f1739d732326cbecbef389\"\naes.decode(\"bef12e48d0f1739d732326cbecbef389\", { key }).text; \u002F\u002F \"ATTACK AT DAWN\"\n","ts","",[162,174,175,211,232,271],{"__ignoreMap":172},[176,177,180,184,188,191,195,199,203,206,208],"span",{"class":178,"line":179},"line",1,[176,181,183],{"class":182},"s1TYA","const",[176,185,187],{"class":186},"saoiD"," aes",[176,189,190],{"class":182}," =",[176,192,194],{"class":193},"sULi6"," create",[176,196,198],{"class":197},"sKlNE","(",[176,200,202],{"class":201},"scVjq","\"",[176,204,156],{"class":205},"sQ7BG",[176,207,202],{"class":201},[176,209,210],{"class":197},");\n",[176,212,214,216,219,221,224,227,229],{"class":178,"line":213},2,[176,215,183],{"class":182},[176,217,218],{"class":186}," key",[176,220,190],{"class":182},[176,222,223],{"class":201}," \"",[176,225,226],{"class":205},"2b7e151628aed2a6abf7158809cf4f3c",[176,228,202],{"class":201},[176,230,231],{"class":197},";\n",[176,233,235,238,241,244,246,248,251,253,256,258,261,264,267],{"class":178,"line":234},3,[176,236,156],{"class":237},"spVlQ",[176,239,240],{"class":197},".",[176,242,243],{"class":193},"encode",[176,245,198],{"class":197},[176,247,202],{"class":201},[176,249,250],{"class":205},"ATTACK AT DAWN",[176,252,202],{"class":201},[176,254,255],{"class":197},", {",[176,257,218],{"class":237},[176,259,260],{"class":197}," }).",[176,262,263],{"class":237},"text",[176,265,266],{"class":197},"; ",[176,268,270],{"class":269},"sjhu3","\u002F\u002F \"bef12e48d0f1739d732326cbecbef389\"\n",[176,272,274,276,278,280,282,284,287,289,291,293,295,297,299],{"class":178,"line":273},4,[176,275,156],{"class":237},[176,277,240],{"class":197},[176,279,164],{"class":193},[176,281,198],{"class":197},[176,283,202],{"class":201},[176,285,286],{"class":205},"bef12e48d0f1739d732326cbecbef389",[176,288,202],{"class":201},[176,290,255],{"class":197},[176,292,218],{"class":237},[176,294,260],{"class":197},[176,296,263],{"class":237},[176,298,266],{"class":197},[176,300,301],{"class":269},"\u002F\u002F \"ATTACK AT DAWN\"\n",[158,303,304],{},"OpenSSL gives the same bytes, so you can check it without this package:",[167,306,310],{"className":307,"code":308,"language":309,"meta":172,"style":172},"language-bash shiki shiki-themes github-light github-light poimandres","printf %s \"ATTACK AT DAWN\" | openssl enc -aes-128-ecb -K 2b7e151628aed2a6abf7158809cf4f3c | xxd -p\n","bash",[162,311,312],{"__ignoreMap":172},[176,313,314,318,322,324,326,328,331,335,338,342,345,348,350,353],{"class":178,"line":179},[176,315,317],{"class":316},"s39Ir","printf",[176,319,321],{"class":320},"sX7Zv"," %s",[176,323,223],{"class":201},[176,325,250],{"class":205},[176,327,202],{"class":201},[176,329,330],{"class":182}," |",[176,332,334],{"class":333},"sseY5"," openssl",[176,336,337],{"class":320}," enc",[176,339,341],{"class":340},"sqT1Y"," -aes-128-ecb",[176,343,344],{"class":340}," -K",[176,346,347],{"class":320}," 2b7e151628aed2a6abf7158809cf4f3c",[176,349,330],{"class":182},[176,351,352],{"class":333}," xxd",[176,354,355],{"class":340}," -p\n",[158,357,358],{},"The block function is tested against the FIPS-197 Appendix C examples and the ECB vectors from NIST SP 800-38A.",[360,361,363],"h2",{"id":362},"why-ecb-leaks","Why ECB leaks",[158,365,366,367,370],{},"Same key, same block, same output. Thirty-two ",[162,368,369],{},"A","s are two identical blocks of plaintext, and they come out as two identical blocks of ciphertext:",[167,372,374],{"className":169,"code":373,"language":171,"meta":172,"style":172},"aes.encode(\"A\".repeat(32), { key: \"000102030405060708090a0b0c0d0e0f\" }).text;\n\u002F\u002F dd4b1a0b47daa7067d0b59d95d58a6ae dd4b1a0b47daa7067d0b59d95d58a6ae 954f64f2e4e86e9eee82d20216684899\n",[162,375,376,425],{"__ignoreMap":172},[176,377,378,380,382,384,386,388,390,392,394,397,399,403,406,409,412,414,417,419,421,423],{"class":178,"line":179},[176,379,156],{"class":237},[176,381,240],{"class":197},[176,383,243],{"class":193},[176,385,198],{"class":197},[176,387,202],{"class":201},[176,389,369],{"class":205},[176,391,202],{"class":201},[176,393,240],{"class":197},[176,395,396],{"class":193},"repeat",[176,398,198],{"class":197},[176,400,402],{"class":401},"siHFe","32",[176,404,405],{"class":197},"), {",[176,407,218],{"class":408},"snHMy",[176,410,411],{"class":197},":",[176,413,223],{"class":201},[176,415,416],{"class":205},"000102030405060708090a0b0c0d0e0f",[176,418,202],{"class":201},[176,420,260],{"class":197},[176,422,263],{"class":237},[176,424,231],{"class":197},[176,426,427],{"class":178,"line":213},[176,428,429],{"class":269},"\u002F\u002F dd4b1a0b47daa7067d0b59d95d58a6ae dd4b1a0b47daa7067d0b59d95d58a6ae 954f64f2e4e86e9eee82d20216684899\n",[158,431,432],{},"Spaces added here to show the blocks. The third block is only padding. That's the whole weakness: nobody learns the key, but anyone sees which blocks repeat, and can cut blocks out or swap them without knowing the key either. It's why ECB is the mode CTFs pick and the mode textbooks warn about.",[158,434,435,436,439,440,443,444,446,447,450],{},"A key that isn't 32, 48 or 64 hex digits is an ",[162,437,438],{},"InvalidOptionError",", a missing one a ",[162,441,442],{},"MissingOptionError",". On ",[162,445,164],{},", a ciphertext that isn't whole 16-byte blocks of hex is a ",[162,448,449],{},"CipherError",". So is a wrong key, because the last block then almost never ends in valid PKCS#7 padding. Decrypted bytes that aren't UTF-8 are an error too, the result is always text.",[158,452,453],{},"This implementation is for learning and for puzzles. It's plain TypeScript with table lookups, not constant time, and ECB hides nothing about the structure of the message. Don't protect anything real with it.",[455,456,457],"style",{},"html pre.shiki code .s1TYA, html code.shiki .s1TYA{--shiki-light:#D73A49;--shiki-default:#D73A49;--shiki-dark:#91B4D5}html pre.shiki code .saoiD, html code.shiki .saoiD{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#E4F0FB}html pre.shiki code .sULi6, html code.shiki .sULi6{--shiki-light:#6F42C1;--shiki-default:#6F42C1;--shiki-dark:#E4F0FBD0}html pre.shiki code .sKlNE, html code.shiki .sKlNE{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#A6ACCD}html pre.shiki code .scVjq, html code.shiki .scVjq{--shiki-light:#032F62;--shiki-default:#032F62;--shiki-dark:#A6ACCD}html pre.shiki code .sQ7BG, html code.shiki .sQ7BG{--shiki-light:#032F62;--shiki-default:#032F62;--shiki-dark:#5DE4C7}html pre.shiki code .spVlQ, html code.shiki .spVlQ{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#E4F0FB}html pre.shiki code .sjhu3, html code.shiki .sjhu3{--shiki-light:#6A737D;--shiki-light-font-style:inherit;--shiki-default:#6A737D;--shiki-default-font-style:inherit;--shiki-dark:#767C9DB0;--shiki-dark-font-style:italic}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);}html pre.shiki code .siHFe, html code.shiki .siHFe{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#5DE4C7}html pre.shiki code .snHMy, html code.shiki .snHMy{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#ADD7FF}html pre.shiki code .s39Ir, html code.shiki .s39Ir{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#91B4D5}html pre.shiki code .sX7Zv, html code.shiki .sX7Zv{--shiki-light:#032F62;--shiki-default:#032F62;--shiki-dark:#ADD7FF}html pre.shiki code .sseY5, html code.shiki .sseY5{--shiki-light:#6F42C1;--shiki-default:#6F42C1;--shiki-dark:#91B4D5}html pre.shiki code .sqT1Y, html code.shiki .sqT1Y{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#ADD7FF}",{"title":172,"searchDepth":213,"depth":213,"links":459},[460],{"id":362,"depth":213,"text":363},"The standard block cipher in its simplest mode. UTF-8 text in, hex out, and every 16-byte block encrypted on its own, so repeats show through.","md",null,{},true,{"title":124,"description":461},"kzPdDv7Wzht_ToznGealWAJNWsxN8BbqSIlO1XTZ1Hc",[469,471],{"title":120,"path":121,"stem":122,"description":470,"children":-1},"A primer starts the key, then the plaintext takes over.",{"title":128,"path":129,"stem":130,"description":472,"children":-1},"DES three times, encrypt, decrypt and encrypt again. UTF-8 text in, hex out, and every 8-byte block encrypted on its own.",1790270049309]