[{"data":1,"prerenderedAt":749},["ShallowReactive",2],{"navigation_docs":3,"-guide-hashing":148,"-guide-hashing-surround":744},[4,40],{"title":5,"path":6,"stem":7,"children":8,"icon":39},"Guide","\u002Fguide","1.guide\u002F01.index",[9,11,15,19,23,27,31,35],{"title":10,"path":6,"stem":7},"Getting Started",{"title":12,"path":13,"stem":14},"Hashing","\u002Fguide\u002Fhashing","1.guide\u002F02.hashing",{"title":16,"path":17,"stem":18},"HMAC and verify","\u002Fguide\u002Fverify","1.guide\u002F03.verify",{"title":20,"path":21,"stem":22},"Salted KDFs","\u002Fguide\u002Fkdf","1.guide\u002F04.kdf",{"title":24,"path":25,"stem":26},"CLI","\u002Fguide\u002Fcli","1.guide\u002F05.cli",{"title":28,"path":29,"stem":30},"Agents","\u002Fguide\u002Fagents","1.guide\u002F06.agents",{"title":32,"path":33,"stem":34},"Custom algorithms","\u002Fguide\u002Fcustom","1.guide\u002F07.custom",{"title":36,"path":37,"stem":38},"Playground","\u002Fguide\u002Fplayground","1.guide\u002F08.playground","i-lucide-book-open",{"title":41,"path":42,"stem":43,"children":44,"icon":147},"Algorithms","\u002Falgorithms","2.algorithms\u002F00.index",[45,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":46,"path":42,"stem":43},"Every algorithm",{"title":48,"path":49,"stem":50},"SHA-256","\u002Falgorithms\u002Fsha256","2.algorithms\u002F01.sha256",{"title":52,"path":53,"stem":54},"SHA-384","\u002Falgorithms\u002Fsha384","2.algorithms\u002F02.sha384",{"title":56,"path":57,"stem":58},"SHA-512","\u002Falgorithms\u002Fsha512","2.algorithms\u002F03.sha512",{"title":60,"path":61,"stem":62},"SHA-512Half","\u002Falgorithms\u002Fsha512-half","2.algorithms\u002F04.sha512-half",{"title":64,"path":65,"stem":66},"SHA3-256","\u002Falgorithms\u002Fsha3-256","2.algorithms\u002F05.sha3-256",{"title":68,"path":69,"stem":70},"SHA3-512","\u002Falgorithms\u002Fsha3-512","2.algorithms\u002F06.sha3-512",{"title":72,"path":73,"stem":74},"Keccak-256","\u002Falgorithms\u002Fkeccak256","2.algorithms\u002F07.keccak256",{"title":76,"path":77,"stem":78},"BLAKE2b","\u002Falgorithms\u002Fblake2b","2.algorithms\u002F08.blake2b",{"title":80,"path":81,"stem":82},"BLAKE2b-256","\u002Falgorithms\u002Fblake2b-256","2.algorithms\u002F09.blake2b-256",{"title":84,"path":85,"stem":86},"BLAKE2b-224","\u002Falgorithms\u002Fblake2b-224","2.algorithms\u002F10.blake2b-224",{"title":88,"path":89,"stem":90},"BLAKE2s","\u002Falgorithms\u002Fblake2s","2.algorithms\u002F11.blake2s",{"title":92,"path":93,"stem":94},"BLAKE3","\u002Falgorithms\u002Fblake3","2.algorithms\u002F12.blake3",{"title":96,"path":97,"stem":98},"BLAKE-256","\u002Falgorithms\u002Fblake256","2.algorithms\u002F13.blake256",{"title":100,"path":101,"stem":102},"RIPEMD-160","\u002Falgorithms\u002Fripemd160","2.algorithms\u002F14.ripemd160",{"title":104,"path":105,"stem":106},"HASH160","\u002Falgorithms\u002Fhash160","2.algorithms\u002F15.hash160",{"title":108,"path":109,"stem":110},"HASH256","\u002Falgorithms\u002Fhash256","2.algorithms\u002F16.hash256",{"title":112,"path":113,"stem":114},"MD5","\u002Falgorithms\u002Fmd5","2.algorithms\u002F17.md5",{"title":116,"path":117,"stem":118},"SHA-1","\u002Falgorithms\u002Fsha1","2.algorithms\u002F18.sha1",{"title":120,"path":121,"stem":122},"SHA-0","\u002Falgorithms\u002Fsha0","2.algorithms\u002F19.sha0",{"title":124,"path":125,"stem":126},"CRC-32","\u002Falgorithms\u002Fcrc32","2.algorithms\u002F20.crc32",{"title":128,"path":129,"stem":130},"CRC-16\u002FXMODEM","\u002Falgorithms\u002Fcrc16-xmodem","2.algorithms\u002F21.crc16-xmodem",{"title":132,"path":133,"stem":134},"xxHash (XXH64)","\u002Falgorithms\u002Fxxhash","2.algorithms\u002F22.xxhash",{"title":136,"path":137,"stem":138},"FNV-1a (64-bit)","\u002Falgorithms\u002Ffnv1a","2.algorithms\u002F23.fnv1a",{"title":140,"path":141,"stem":142},"scrypt","\u002Falgorithms\u002Fscrypt","2.algorithms\u002F24.scrypt",{"title":144,"path":145,"stem":146},"PBKDF2","\u002Falgorithms\u002Fpbkdf2","2.algorithms\u002F25.pbkdf2","i-lucide-library",{"id":149,"title":12,"body":150,"description":737,"extension":738,"links":739,"meta":740,"navigation":196,"path":13,"seo":742,"stem":14,"__hash__":743},"docs\u002F1.guide\u002F02.hashing.md",{"type":151,"value":152,"toc":730},"minimark",[153,158,326,350,354,360,432,452,462,466,480,567,574,578,584,656,674,678,681,713,726],[154,155,157],"h2",{"id":156},"one-method","One method",[159,160,165],"pre",{"className":161,"code":162,"language":163,"meta":164,"style":164},"language-ts shiki shiki-themes hashes hashes hashes","import { create } from \"@agntn\u002Fhashes\";\n\nconst sha256 = create(\"sha256\");\n\nsha256.hash(\"abc\").digest;\n\u002F\u002F \"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad\"\nsha256.hash(\"abc\", { encoding: \"base64\" }).digest;\n\u002F\u002F \"ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD\u002FYfIAFa0=\"\nsha256.hash(\"abc\", { encoding: \"base64url\" }).digest;\n\u002F\u002F \"ungWv48Bz-pBQUDeXa4iI7ADYaOWF3qctBD_YfIAFa0\"\nsha256.hash(\"abc\", { encoding: \"binary\" }).digest;\n\u002F\u002F Uint8Array(32)\n","ts","",[166,167,168,191,198,223,228,245,252,272,278,296,302,320],"code",{"__ignoreMap":164},[169,170,173,177,181,184,188],"span",{"class":171,"line":172},"line",1,[169,174,176],{"class":175},"skH_V","import",[169,178,180],{"class":179},"s38Sx"," { create } ",[169,182,183],{"class":175},"from",[169,185,187],{"class":186},"shU9J"," \"@agntn\u002Fhashes\"",[169,189,190],{"class":179},";\n",[169,192,194],{"class":171,"line":193},2,[169,195,197],{"emptyLinePlaceholder":196},true,"\n",[169,199,201,204,207,210,214,217,220],{"class":171,"line":200},3,[169,202,203],{"class":175},"const",[169,205,206],{"class":179}," sha256 ",[169,208,209],{"class":175},"=",[169,211,213],{"class":212},"sK71F"," create",[169,215,216],{"class":179},"(",[169,218,219],{"class":186},"\"sha256\"",[169,221,222],{"class":179},");\n",[169,224,226],{"class":171,"line":225},4,[169,227,197],{"emptyLinePlaceholder":196},[169,229,231,234,237,239,242],{"class":171,"line":230},5,[169,232,233],{"class":179},"sha256.",[169,235,236],{"class":212},"hash",[169,238,216],{"class":179},[169,240,241],{"class":186},"\"abc\"",[169,243,244],{"class":179},").digest;\n",[169,246,248],{"class":171,"line":247},6,[169,249,251],{"class":250},"scIB-","\u002F\u002F \"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad\"\n",[169,253,255,257,259,261,263,266,269],{"class":171,"line":254},7,[169,256,233],{"class":179},[169,258,236],{"class":212},[169,260,216],{"class":179},[169,262,241],{"class":186},[169,264,265],{"class":179},", { encoding: ",[169,267,268],{"class":186},"\"base64\"",[169,270,271],{"class":179}," }).digest;\n",[169,273,275],{"class":171,"line":274},8,[169,276,277],{"class":250},"\u002F\u002F \"ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD\u002FYfIAFa0=\"\n",[169,279,281,283,285,287,289,291,294],{"class":171,"line":280},9,[169,282,233],{"class":179},[169,284,236],{"class":212},[169,286,216],{"class":179},[169,288,241],{"class":186},[169,290,265],{"class":179},[169,292,293],{"class":186},"\"base64url\"",[169,295,271],{"class":179},[169,297,299],{"class":171,"line":298},10,[169,300,301],{"class":250},"\u002F\u002F \"ungWv48Bz-pBQUDeXa4iI7ADYaOWF3qctBD_YfIAFa0\"\n",[169,303,305,307,309,311,313,315,318],{"class":171,"line":304},11,[169,306,233],{"class":179},[169,308,236],{"class":212},[169,310,216],{"class":179},[169,312,241],{"class":186},[169,314,265],{"class":179},[169,316,317],{"class":186},"\"binary\"",[169,319,271],{"class":179},[169,321,323],{"class":171,"line":322},12,[169,324,325],{"class":250},"\u002F\u002F Uint8Array(32)\n",[327,328,329,330,333,334,337,338,341,342,345,346,349],"p",{},"That's the whole API for most people. ",[166,331,332],{},"hash(input, options)"," on any algorithm, the same result shape back. ",[166,335,336],{},"hex"," is the default. ",[166,339,340],{},"base64url"," drops the padding, the way JWTs write it. ",[166,343,344],{},"binary"," hands you the raw ",[166,347,348],{},"Uint8Array",", which is what you want before you feed the digest into another hash.",[154,351,353],{"id":352},"text-or-bytes","Text or bytes",[327,355,356,357,359],{},"A string is read as UTF-8. A ",[166,358,348],{}," is hashed as it is. The difference matters the moment your input is already bytes written as hex, like a public key:",[159,361,363],{"className":161,"code":362,"language":163,"meta":164,"style":164},"const key = \"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\";\n\ncreate(\"hash160\").hash(key).digest;\n\u002F\u002F \"b170e26bb62fb9dbfa28bb2f5e320c96459a2bed\", the 66 characters, hashed as text\ncreate(\"hash160\").hash(Uint8Array.fromHex(key)).digest;\n\u002F\u002F \"751e76e8199196d454941c45d1b3a323f1433bd6\", the 33 bytes, which is what Bitcoin hashes\n",[166,364,365,379,383,401,406,427],{"__ignoreMap":164},[169,366,367,369,372,374,377],{"class":171,"line":172},[169,368,203],{"class":175},[169,370,371],{"class":179}," key ",[169,373,209],{"class":175},[169,375,376],{"class":186}," \"0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798\"",[169,378,190],{"class":179},[169,380,381],{"class":171,"line":193},[169,382,197],{"emptyLinePlaceholder":196},[169,384,385,388,390,393,396,398],{"class":171,"line":200},[169,386,387],{"class":212},"create",[169,389,216],{"class":179},[169,391,392],{"class":186},"\"hash160\"",[169,394,395],{"class":179},").",[169,397,236],{"class":212},[169,399,400],{"class":179},"(key).digest;\n",[169,402,403],{"class":171,"line":225},[169,404,405],{"class":250},"\u002F\u002F \"b170e26bb62fb9dbfa28bb2f5e320c96459a2bed\", the 66 characters, hashed as text\n",[169,407,408,410,412,414,416,418,421,424],{"class":171,"line":230},[169,409,387],{"class":212},[169,411,216],{"class":179},[169,413,392],{"class":186},[169,415,395],{"class":179},[169,417,236],{"class":212},[169,419,420],{"class":179},"(Uint8Array.",[169,422,423],{"class":212},"fromHex",[169,425,426],{"class":179},"(key)).digest;\n",[169,428,429],{"class":171,"line":247},[169,430,431],{"class":250},"\u002F\u002F \"751e76e8199196d454941c45d1b3a323f1433bd6\", the 33 bytes, which is what Bitcoin hashes\n",[327,433,434,435,437,438,441,442,445,446,441,449,451],{},"The first one is a perfectly valid digest of a string nobody meant. That's the classic bug, and it's silent. The library takes bytes, so pass bytes. The CLI and the agent tools can't pass a ",[166,436,348],{},", so they take ",[166,439,440],{},"--input-encoding hex"," and ",[166,443,444],{},"inputEncoding: \"hex\""," instead and decode it for you. See ",[447,448,24],"a",{"href":25},[447,450,28],{"href":29},".",[327,453,454,455,441,458,461],{},"Non-ASCII text is fine, UTF-8 is UTF-8. ",[166,456,457],{},"\"żółw\"",[166,459,460],{},"new TextEncoder().encode(\"żółw\")"," give the same digest.",[154,463,465],{"id":464},"names","Names",[327,467,468,471,472,475,476,479],{},[166,469,470],{},"create()"," is strict: the exact registry key or an ",[166,473,474],{},"UnknownAlgorithmError",". For names a human typed, use ",[166,477,478],{},"resolveAlgorithm()",". It lowercases, turns spaces and underscores into hyphens and then looks the result up, nothing smarter.",[159,481,483],{"className":161,"code":482,"language":163,"meta":164,"style":164},"import { algorithms, has, resolveAlgorithm } from \"@agntn\u002Fhashes\";\n\nresolveAlgorithm(\"SHA3_256\").name(); \u002F\u002F \"sha3-256\"\nresolveAlgorithm(\"Blake2b 256\").name(); \u002F\u002F \"blake2b-256\"\nhas(\"sha224\"); \u002F\u002F false, unless you registered one\nalgorithms(); \u002F\u002F every key, built-ins in listing order, then yours\n",[166,484,485,498,502,523,541,557],{"__ignoreMap":164},[169,486,487,489,492,494,496],{"class":171,"line":172},[169,488,176],{"class":175},[169,490,491],{"class":179}," { algorithms, has, resolveAlgorithm } ",[169,493,183],{"class":175},[169,495,187],{"class":186},[169,497,190],{"class":179},[169,499,500],{"class":171,"line":193},[169,501,197],{"emptyLinePlaceholder":196},[169,503,504,507,509,512,514,517,520],{"class":171,"line":200},[169,505,506],{"class":212},"resolveAlgorithm",[169,508,216],{"class":179},[169,510,511],{"class":186},"\"SHA3_256\"",[169,513,395],{"class":179},[169,515,516],{"class":212},"name",[169,518,519],{"class":179},"(); ",[169,521,522],{"class":250},"\u002F\u002F \"sha3-256\"\n",[169,524,525,527,529,532,534,536,538],{"class":171,"line":225},[169,526,506],{"class":212},[169,528,216],{"class":179},[169,530,531],{"class":186},"\"Blake2b 256\"",[169,533,395],{"class":179},[169,535,516],{"class":212},[169,537,519],{"class":179},[169,539,540],{"class":250},"\u002F\u002F \"blake2b-256\"\n",[169,542,543,546,548,551,554],{"class":171,"line":230},[169,544,545],{"class":212},"has",[169,547,216],{"class":179},[169,549,550],{"class":186},"\"sha224\"",[169,552,553],{"class":179},"); ",[169,555,556],{"class":250},"\u002F\u002F false, unless you registered one\n",[169,558,559,562,564],{"class":171,"line":247},[169,560,561],{"class":212},"algorithms",[169,563,519],{"class":179},[169,565,566],{"class":250},"\u002F\u002F every key, built-ins in listing order, then yours\n",[327,568,569,570,573],{},"No fuzzy match on purpose. ",[166,571,572],{},"sha3"," could mean four different things, and guessing is how you get a wrong digest that looks right.",[154,575,577],{"id":576},"what-an-algorithm-says-about-itself","What an algorithm says about itself",[327,579,580,583],{},[166,581,582],{},"info()"," is how an algorithm describes itself, and the site, the CLI and the tools all read it:",[159,585,587],{"className":161,"code":586,"language":163,"meta":164,"style":164},"create(\"keccak256\").info();\n\u002F\u002F {\n\u002F\u002F   name: \"keccak256\",\n\u002F\u002F   label: \"Keccak-256\",\n\u002F\u002F   family: \"cryptographic\",\n\u002F\u002F   digestLength: 32,\n\u002F\u002F   hmac: true,\n\u002F\u002F   options: [{ name: \"encoding\", ... }, { name: \"key\", ... }],\n\u002F\u002F   securityNote: \"128-bit collision resistance, ...\",\n\u002F\u002F   ...\n\u002F\u002F }\n",[166,588,589,606,611,616,621,626,631,636,641,646,651],{"__ignoreMap":164},[169,590,591,593,595,598,600,603],{"class":171,"line":172},[169,592,387],{"class":212},[169,594,216],{"class":179},[169,596,597],{"class":186},"\"keccak256\"",[169,599,395],{"class":179},[169,601,602],{"class":212},"info",[169,604,605],{"class":179},"();\n",[169,607,608],{"class":171,"line":193},[169,609,610],{"class":250},"\u002F\u002F {\n",[169,612,613],{"class":171,"line":200},[169,614,615],{"class":250},"\u002F\u002F   name: \"keccak256\",\n",[169,617,618],{"class":171,"line":225},[169,619,620],{"class":250},"\u002F\u002F   label: \"Keccak-256\",\n",[169,622,623],{"class":171,"line":230},[169,624,625],{"class":250},"\u002F\u002F   family: \"cryptographic\",\n",[169,627,628],{"class":171,"line":247},[169,629,630],{"class":250},"\u002F\u002F   digestLength: 32,\n",[169,632,633],{"class":171,"line":254},[169,634,635],{"class":250},"\u002F\u002F   hmac: true,\n",[169,637,638],{"class":171,"line":274},[169,639,640],{"class":250},"\u002F\u002F   options: [{ name: \"encoding\", ... }, { name: \"key\", ... }],\n",[169,642,643],{"class":171,"line":280},[169,644,645],{"class":250},"\u002F\u002F   securityNote: \"128-bit collision resistance, ...\",\n",[169,647,648],{"class":171,"line":298},[169,649,650],{"class":250},"\u002F\u002F   ...\n",[169,652,653],{"class":171,"line":304},[169,654,655],{"class":250},"\u002F\u002F }\n",[327,657,658,661,662,665,666,669,670,673],{},[166,659,660],{},"options"," lists everything the algorithm takes, with type, default and description. A KDF declares ",[166,663,664],{},"salt"," and its costs there, xxHash its ",[166,667,668],{},"seed",". The CLI turns them into flags and the tools take them as ",[166,671,672],{},"parameters",", so an option you add in one place reaches all of them.",[154,675,677],{"id":676},"families","Families",[327,679,680],{},"Four of them, and they mean what they say:",[682,683,684,692,698,704],"ul",{},[685,686,687,691],"li",{},[688,689,690],"strong",{},"cryptographic."," SHA-2, SHA-3, Keccak, BLAKE, RIPEMD-160 and the Bitcoin compositions. Use these when it matters.",[685,693,694,697],{},[688,695,696],{},"legacy."," MD5, SHA-1 and SHA-0. Broken for collisions, the first two still in every checksum file and inside Git. Fine for matching a checksum somebody else published. Not fine for anything you'd sign.",[685,699,700,703],{},[688,701,702],{},"non-cryptographic."," CRC-32, CRC-16\u002FXMODEM, xxHash, FNV-1a. Fast, tiny, trivial to collide on purpose. Tables, dedup, error detection.",[685,705,706,709,710,451],{},[688,707,708],{},"password."," scrypt and PBKDF2. Slow on purpose, and they need a salt. They have ",[447,711,712],{"href":21},"their own page",[327,714,715,441,718,721,722,725],{},[166,716,717],{},"hashes algorithms -f legacy",[166,719,720],{},"hash_algorithms"," with ",[166,723,724],{},"family"," list one of them.",[727,728,729],"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 .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 .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 .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":164,"searchDepth":193,"depth":193,"links":731},[732,733,734,735,736],{"id":156,"depth":193,"text":157},{"id":352,"depth":193,"text":353},{"id":464,"depth":193,"text":465},{"id":576,"depth":193,"text":577},{"id":676,"depth":193,"text":677},"Pick an algorithm by name and hash text or bytes. Hex and base64 and base64url or raw bytes out","md",null,{"icon":741},"i-lucide-hash",{"title":12,"description":737},"SxdcQQqIqrrvPGe7ECGl8jj2KbY9IfAbSVp8cGes80s",[745,747],{"title":10,"path":6,"stem":7,"description":746,"children":-1},"Install the package and hash one string. Every algorithm answers with the same result shape",{"title":16,"path":17,"stem":18,"description":748,"children":-1},"Key a digest with HMAC and compare an expected digest byte for byte. Hex ignores case and base64 never does",1790683655811]