[{"data":1,"prerenderedAt":674},["ShallowReactive",2],{"navigation_docs":3,"-ciphers-des":204,"-ciphers-des-surround":669},[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":203},"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],{"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",{"title":148,"path":149,"stem":150},"AES (CCM)","\u002Fciphers\u002Faes-ccm","2.ciphers\u002F27.aes-ccm",{"title":152,"path":153,"stem":154},"AES (OFB)","\u002Fciphers\u002Faes-ofb","2.ciphers\u002F28.aes-ofb",{"title":156,"path":157,"stem":158},"AES (OCB)","\u002Fciphers\u002Faes-ocb","2.ciphers\u002F29.aes-ocb",{"title":160,"path":161,"stem":162},"Triple DES (CBC)","\u002Fciphers\u002Ftriple-des-cbc","2.ciphers\u002F30.triple-des-cbc",{"title":164,"path":165,"stem":166},"Rijndael (ECB)","\u002Fciphers\u002Frijndael","2.ciphers\u002F31.rijndael",{"title":168,"path":169,"stem":170},"AES (XTS)","\u002Fciphers\u002Faes-xts","2.ciphers\u002F32.aes-xts",{"title":172,"path":173,"stem":174},"AES (CBC-MAC)","\u002Fciphers\u002Faes-cbc-mac","2.ciphers\u002F33.aes-cbc-mac",{"title":176,"path":177,"stem":178},"Blowfish (ECB)","\u002Fciphers\u002Fblowfish","2.ciphers\u002F34.blowfish",{"title":180,"path":181,"stem":182},"DES (ECB)","\u002Fciphers\u002Fdes","2.ciphers\u002F35.des",{"title":184,"path":185,"stem":186},"DESX (ECB)","\u002Fciphers\u002Fdesx","2.ciphers\u002F36.desx",{"title":188,"path":189,"stem":190},"IDEA (ECB)","\u002Fciphers\u002Fidea","2.ciphers\u002F37.idea",{"title":192,"path":193,"stem":194},"Lucifer (ECB)","\u002Fciphers\u002Flucifer","2.ciphers\u002F38.lucifer",{"title":196,"path":197,"stem":198},"MARS (ECB)","\u002Fciphers\u002Fmars","2.ciphers\u002F39.mars",{"title":200,"path":201,"stem":202},"Serpent (ECB)","\u002Fciphers\u002Fserpent","2.ciphers\u002F40.serpent","i-solar-library-linear",{"id":205,"title":180,"body":206,"description":662,"extension":663,"links":664,"meta":665,"navigation":666,"path":181,"seo":667,"stem":182,"__hash__":668},"docs\u002F2.ciphers\u002F35.des.md",{"type":207,"value":208,"toc":657},"minimark",[209,213,217,230,365,368,430,437,442,448,558,562,569,573,580,626,629,650,653],[210,211],"cipher-facts",{"name":212},"des",[214,215,216],"p",{},"DES came out of IBM, got picked by the US National Bureau of Standards and went out as FIPS 46 in 1977. For twenty years it was the cipher. The block is 64 bits and so is the key, but the last bit of every key byte is parity and nothing reads it. That leaves 56 bits. The key here is 16 hex digits, case doesn't matter and spaces are ignored.",[214,218,219,220,224,225,229],{},"Text goes in as UTF-8 with PKCS#7 padding, ciphertext comes out as lowercase hex, and ",[221,222,223],"code",{},"decode"," wants hex back. The mode is ECB, same as ",[226,227,228],"a",{"href":129},"Triple DES",".",[231,232,237],"pre",{"className":233,"code":234,"language":235,"meta":236,"style":236},"language-ts shiki shiki-themes github-light github-light poimandres","const des = create(\"des\");\nconst key = \"0123456789abcdef\";\ndes.encode(\"ATTACK AT DAWN\", { key }).text; \u002F\u002F \"66e43480bc9810be67812271f1ee04a0\"\ndes.decode(\"66e43480bc9810be67812271f1ee04a0\", { key }).text; \u002F\u002F \"ATTACK AT DAWN\"\n","ts","",[221,238,239,275,296,334],{"__ignoreMap":236},[240,241,244,248,252,255,259,263,267,270,272],"span",{"class":242,"line":243},"line",1,[240,245,247],{"class":246},"s1TYA","const",[240,249,251],{"class":250},"saoiD"," des",[240,253,254],{"class":246}," =",[240,256,258],{"class":257},"sULi6"," create",[240,260,262],{"class":261},"sKlNE","(",[240,264,266],{"class":265},"scVjq","\"",[240,268,212],{"class":269},"sQ7BG",[240,271,266],{"class":265},[240,273,274],{"class":261},");\n",[240,276,278,280,283,285,288,291,293],{"class":242,"line":277},2,[240,279,247],{"class":246},[240,281,282],{"class":250}," key",[240,284,254],{"class":246},[240,286,287],{"class":265}," \"",[240,289,290],{"class":269},"0123456789abcdef",[240,292,266],{"class":265},[240,294,295],{"class":261},";\n",[240,297,299,302,304,307,309,311,314,316,319,321,324,327,330],{"class":242,"line":298},3,[240,300,212],{"class":301},"spVlQ",[240,303,229],{"class":261},[240,305,306],{"class":257},"encode",[240,308,262],{"class":261},[240,310,266],{"class":265},[240,312,313],{"class":269},"ATTACK AT DAWN",[240,315,266],{"class":265},[240,317,318],{"class":261},", {",[240,320,282],{"class":301},[240,322,323],{"class":261}," }).",[240,325,326],{"class":301},"text",[240,328,329],{"class":261},"; ",[240,331,333],{"class":332},"sjhu3","\u002F\u002F \"66e43480bc9810be67812271f1ee04a0\"\n",[240,335,337,339,341,343,345,347,350,352,354,356,358,360,362],{"class":242,"line":336},4,[240,338,212],{"class":301},[240,340,229],{"class":261},[240,342,223],{"class":257},[240,344,262],{"class":261},[240,346,266],{"class":265},[240,348,349],{"class":269},"66e43480bc9810be67812271f1ee04a0",[240,351,266],{"class":265},[240,353,318],{"class":261},[240,355,282],{"class":301},[240,357,323],{"class":261},[240,359,326],{"class":301},[240,361,329],{"class":261},[240,363,364],{"class":332},"\u002F\u002F \"ATTACK AT DAWN\"\n",[214,366,367],{},"OpenSSL agrees, but since 3.0 single DES lives in the legacy provider:",[231,369,373],{"className":370,"code":371,"language":372,"meta":236,"style":236},"language-bash shiki shiki-themes github-light github-light poimandres","printf %s \"ATTACK AT DAWN\" | openssl enc -des-ecb -provider legacy -provider default -K 0123456789abcdef | xxd -p\n","bash",[221,374,375],{"__ignoreMap":236},[240,376,377,381,385,387,389,391,394,398,401,405,408,411,413,416,419,422,424,427],{"class":242,"line":243},[240,378,380],{"class":379},"s39Ir","printf",[240,382,384],{"class":383},"sX7Zv"," %s",[240,386,287],{"class":265},[240,388,313],{"class":269},[240,390,266],{"class":265},[240,392,393],{"class":246}," |",[240,395,397],{"class":396},"sseY5"," openssl",[240,399,400],{"class":383}," enc",[240,402,404],{"class":403},"sqT1Y"," -des-ecb",[240,406,407],{"class":403}," -provider",[240,409,410],{"class":383}," legacy",[240,412,407],{"class":403},[240,414,415],{"class":383}," default",[240,417,418],{"class":403}," -K",[240,420,421],{"class":383}," 0123456789abcdef",[240,423,393],{"class":246},[240,425,426],{"class":396}," xxd",[240,428,429],{"class":403}," -p\n",[214,431,432,433,436],{},"The tests start from the ECB example in FIPS 81, ",[221,434,435],{},"Now is the time for all "," under this same key, three blocks. Then Grabbe's walkthrough from \"The DES Algorithm Illustrated\" and a few known answers from NIST SP 800-17.",[438,439,441],"h2",{"id":440},"one-des-three-des","One DES, three DES",[214,443,444,445,447],{},"This is the same DES that ",[226,446,228],{"href":129}," runs three times. Give Triple DES one key three times and the middle decryption undoes the first encryption, so what's left is this:",[231,449,451],{"className":233,"code":450,"language":235,"meta":236,"style":236},"des.encode(\"ATTACK AT DAWN\", { key: \"133457799bbcdff1\" }).text;\n\u002F\u002F \"1739739759a5caa5b6544c0af3cad197\"\ncreate(\"triple-des\").encode(\"ATTACK AT DAWN\", { key: \"133457799bbcdff1\".repeat(3) }).text;\n\u002F\u002F \"1739739759a5caa5b6544c0af3cad197\"\n",[221,452,453,490,495,554],{"__ignoreMap":236},[240,454,455,457,459,461,463,465,467,469,471,474,477,479,482,484,486,488],{"class":242,"line":243},[240,456,212],{"class":301},[240,458,229],{"class":261},[240,460,306],{"class":257},[240,462,262],{"class":261},[240,464,266],{"class":265},[240,466,313],{"class":269},[240,468,266],{"class":265},[240,470,318],{"class":261},[240,472,282],{"class":473},"snHMy",[240,475,476],{"class":261},":",[240,478,287],{"class":265},[240,480,481],{"class":269},"133457799bbcdff1",[240,483,266],{"class":265},[240,485,323],{"class":261},[240,487,326],{"class":301},[240,489,295],{"class":261},[240,491,492],{"class":242,"line":277},[240,493,494],{"class":332},"\u002F\u002F \"1739739759a5caa5b6544c0af3cad197\"\n",[240,496,497,500,502,504,507,509,512,514,516,518,520,522,524,526,528,530,532,534,536,539,541,545,548,550,552],{"class":242,"line":298},[240,498,499],{"class":257},"create",[240,501,262],{"class":261},[240,503,266],{"class":265},[240,505,506],{"class":269},"triple-des",[240,508,266],{"class":265},[240,510,511],{"class":261},").",[240,513,306],{"class":257},[240,515,262],{"class":261},[240,517,266],{"class":265},[240,519,313],{"class":269},[240,521,266],{"class":265},[240,523,318],{"class":261},[240,525,282],{"class":473},[240,527,476],{"class":261},[240,529,287],{"class":265},[240,531,481],{"class":269},[240,533,266],{"class":265},[240,535,229],{"class":261},[240,537,538],{"class":257},"repeat",[240,540,262],{"class":261},[240,542,544],{"class":543},"siHFe","3",[240,546,547],{"class":261},")",[240,549,323],{"class":261},[240,551,326],{"class":301},[240,553,295],{"class":261},[240,555,556],{"class":242,"line":336},[240,557,494],{"class":332},[438,559,561],{"id":560},"weak-keys","Weak keys",[214,563,564,565,568],{},"A few keys make all 16 round keys the same. ",[221,566,567],{},"0101010101010101"," is one of them. Under such a key the rounds read the same forwards and backwards, so encrypting twice gives the text back. FIPS 74 lists four of these and twelve semi-weak ones that come in pairs. Nothing here rejects them, so they're good for poking at.",[438,570,572],{"id":571},"why-ecb-leaks","Why ECB leaks",[214,574,575,576,579],{},"Sixteen ",[221,577,578],{},"A","s are two equal blocks, and they come out as two equal blocks:",[231,581,583],{"className":233,"code":582,"language":235,"meta":236,"style":236},"des.encode(\"A\".repeat(16), { key }).text;\n\u002F\u002F a827de10956a609d a827de10956a609d 086f9a1d74c94d4e\n",[221,584,585,621],{"__ignoreMap":236},[240,586,587,589,591,593,595,597,599,601,603,605,607,610,613,615,617,619],{"class":242,"line":243},[240,588,212],{"class":301},[240,590,229],{"class":261},[240,592,306],{"class":257},[240,594,262],{"class":261},[240,596,266],{"class":265},[240,598,578],{"class":269},[240,600,266],{"class":265},[240,602,229],{"class":261},[240,604,538],{"class":257},[240,606,262],{"class":261},[240,608,609],{"class":543},"16",[240,611,612],{"class":261},"), {",[240,614,282],{"class":301},[240,616,323],{"class":261},[240,618,326],{"class":301},[240,620,295],{"class":261},[240,622,623],{"class":242,"line":277},[240,624,625],{"class":332},"\u002F\u002F a827de10956a609d a827de10956a609d 086f9a1d74c94d4e\n",[214,627,628],{},"Spaces added to show the blocks. The last one is only padding.",[214,630,631,632,635,636,639,640,642,643,646,647,649],{},"A key that isn't 16 hex digits is an ",[221,633,634],{},"InvalidOptionError",", a missing one a ",[221,637,638],{},"MissingOptionError",". On ",[221,641,223],{},", ciphertext that isn't whole 8-byte blocks of hex is a ",[221,644,645],{},"CipherError",". A wrong key almost always breaks the padding, and that's a ",[221,648,645],{}," too. So are decrypted bytes that aren't UTF-8.",[214,651,652],{},"The cipher itself held up well. Differential and linear cryptanalysis both beat brute force on paper, but they want an unrealistic pile of chosen or known plaintexts. The key is what gave out. In 1998 the EFF built Deep Crack and found a DES key in 56 hours. A year later, together with distributed.net, it took 22 hours and 15 minutes. NIST withdrew FIPS 46-3 in 2005. This one is plain TypeScript over bit arrays, slow and not constant time. Puzzles and learning, not secrets.",[654,655,656],"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 .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}html pre.shiki code .snHMy, html code.shiki .snHMy{--shiki-light:#24292E;--shiki-default:#24292E;--shiki-dark:#ADD7FF}html pre.shiki code .siHFe, html code.shiki .siHFe{--shiki-light:#005CC5;--shiki-default:#005CC5;--shiki-dark:#5DE4C7}",{"title":236,"searchDepth":277,"depth":277,"links":658},[659,660,661],{"id":440,"depth":277,"text":441},{"id":560,"depth":277,"text":561},{"id":571,"depth":277,"text":572},"The Data Encryption Standard, one pass of 16 Feistel rounds under a 56-bit key. UTF-8 text in, hex out, and every 8-byte block encrypted on its own.","md",null,{},true,{"title":180,"description":662},"opRs5uq--oGUBj9kNb1fnE__yM4bVpJSCaZ_xdciRbo",[670,672],{"title":176,"path":177,"stem":178,"description":671,"children":-1},"Schneier's 1993 Feistel cipher, with S-boxes cooked from the key and the digits of pi. Keys from 32 to 448 bits, UTF-8 text in, hex out.",{"title":184,"path":185,"stem":186,"description":673,"children":-1},"Rivest's cheap fix for the DES key, one XOR before and one after. Same speed as DES, 184 key bits, UTF-8 text in, hex out.",1790331129569]