[{"data":1,"prerenderedAt":796},["ShallowReactive",2],{"guide-hashing-algorithms-explained":3},{"id":4,"title":5,"body":6,"date":786,"description":787,"extension":788,"meta":789,"navigation":790,"path":791,"readingTime":792,"seo":793,"stem":794,"__hash__":795},"guides\u002Fguides\u002Fhashing-algorithms-explained.md","Hashing Algorithms Explained: SHA-1, SHA-256, SHA-512",{"type":7,"value":8,"toc":765},"minimark",[9,14,23,30,35,69,73,80,84,104,107,217,223,227,243,246,320,325,329,346,349,423,428,432,575,579,586,594,611,615,618,629,632,636,640,670,674,688,692,698,704,710,716,720,741,745,753,756,761],[10,11,13],"h2",{"id":12},"what-is-hashing","What Is Hashing?",[15,16,17,18,22],"p",{},"A hash function takes any input — a word, a file, or a terabyte of data — and produces a fixed-length string of characters called a ",[19,20,21],"strong",{},"hash digest",". The same input always generates the same output. Change one character, and the entire hash changes.",[15,24,25,26,29],{},"Hashing is ",[19,27,28],{},"one-way",". You cannot reconstruct the original data from the hash. That property makes hashing essential for data integrity, password storage, and digital signatures.",[31,32,34],"h3",{"id":33},"key-properties-of-cryptographic-hash-functions","Key Properties of Cryptographic Hash Functions",[36,37,38,45,51,57,63],"ul",{},[39,40,41,44],"li",{},[19,42,43],{},"Deterministic",": Same input always produces the same output",[39,46,47,50],{},[19,48,49],{},"Fixed output size",": SHA-256 always produces 256 bits, regardless of input size",[39,52,53,56],{},[19,54,55],{},"Avalanche effect",": A tiny change in input causes a completely different hash",[39,58,59,62],{},[19,60,61],{},"Irreversible",": Computationally infeasible to derive input from output",[39,64,65,68],{},[19,66,67],{},"Collision resistant",": Extremely unlikely for two different inputs to produce the same hash",[10,70,72],{"id":71},"the-sha-family","The SHA Family",[15,74,75,76,79],{},"The ",[19,77,78],{},"Secure Hash Algorithm (SHA)"," family is the most widely used set of cryptographic hash functions, published by NIST. All three versions covered here follow the same Merkle-Damgård construction but differ in output size and internal processing.",[31,81,83],{"id":82},"sha-1","SHA-1",[36,85,86,92,98],{},[39,87,88,91],{},[19,89,90],{},"Output",": 160 bits (40 hex characters)",[39,93,94,97],{},[19,95,96],{},"Block size",": 512 bits",[39,99,100,103],{},[19,101,102],{},"Status",": Deprecated for security use since 2017",[15,105,106],{},"SHA-1 was the standard for over a decade. In 2017, Google and CWI Amsterdam demonstrated a practical collision attack (SHAttered), proving that two different PDF files could produce the same SHA-1 hash. This broke the核心 collision resistance property.",[108,109,114],"pre",{"className":110,"code":111,"language":112,"meta":113,"style":113},"language-javascript shiki shiki-themes github-light github-dark","\u002F\u002F SHA-1 example (Node.js)\nconst crypto = require('crypto');\nconst hash = crypto.createHash('sha1').update('hello world').digest('hex');\nconsole.log(hash);\n\u002F\u002F Output: 2aae6c35c94fcfb415dbe95f408b9ce91ee846ed\n","javascript","",[115,116,117,126,155,199,211],"code",{"__ignoreMap":113},[118,119,122],"span",{"class":120,"line":121},"line",1,[118,123,125],{"class":124},"sJ8bj","\u002F\u002F SHA-1 example (Node.js)\n",[118,127,129,133,137,140,144,148,152],{"class":120,"line":128},2,[118,130,132],{"class":131},"szBVR","const",[118,134,136],{"class":135},"sj4cs"," crypto",[118,138,139],{"class":131}," =",[118,141,143],{"class":142},"sScJk"," require",[118,145,147],{"class":146},"sVt8B","(",[118,149,151],{"class":150},"sZZnC","'crypto'",[118,153,154],{"class":146},");\n",[118,156,158,160,163,165,168,171,173,176,179,182,184,187,189,192,194,197],{"class":120,"line":157},3,[118,159,132],{"class":131},[118,161,162],{"class":135}," hash",[118,164,139],{"class":131},[118,166,167],{"class":146}," crypto.",[118,169,170],{"class":142},"createHash",[118,172,147],{"class":146},[118,174,175],{"class":150},"'sha1'",[118,177,178],{"class":146},").",[118,180,181],{"class":142},"update",[118,183,147],{"class":146},[118,185,186],{"class":150},"'hello world'",[118,188,178],{"class":146},[118,190,191],{"class":142},"digest",[118,193,147],{"class":146},[118,195,196],{"class":150},"'hex'",[118,198,154],{"class":146},[118,200,202,205,208],{"class":120,"line":201},4,[118,203,204],{"class":146},"console.",[118,206,207],{"class":142},"log",[118,209,210],{"class":146},"(hash);\n",[118,212,214],{"class":120,"line":213},5,[118,215,216],{"class":124},"\u002F\u002F Output: 2aae6c35c94fcfb415dbe95f408b9ce91ee846ed\n",[15,218,219,222],{},[19,220,221],{},"Verdict",": Do not use SHA-1 for any security-sensitive application. It remains useful only for legacy compatibility and non-security checksums.",[31,224,226],{"id":225},"sha-256","SHA-256",[36,228,229,234,238],{},[39,230,231,233],{},[19,232,90],{},": 256 bits (64 hex characters)",[39,235,236,97],{},[19,237,96],{},[39,239,240,242],{},[19,241,102],{},": Current standard, widely trusted",[15,244,245],{},"SHA-256 is part of the SHA-2 family and is the default choice for most applications today. It powers TLS certificates, blockchain networks (Bitcoin), code signing, and software integrity checks.",[108,247,249],{"className":110,"code":248,"language":112,"meta":113,"style":113},"\u002F\u002F SHA-256 example (Node.js)\nconst crypto = require('crypto');\nconst hash = crypto.createHash('sha256').update('hello world').digest('hex');\nconsole.log(hash);\n\u002F\u002F Output: b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9\n",[115,250,251,256,272,307,315],{"__ignoreMap":113},[118,252,253],{"class":120,"line":121},[118,254,255],{"class":124},"\u002F\u002F SHA-256 example (Node.js)\n",[118,257,258,260,262,264,266,268,270],{"class":120,"line":128},[118,259,132],{"class":131},[118,261,136],{"class":135},[118,263,139],{"class":131},[118,265,143],{"class":142},[118,267,147],{"class":146},[118,269,151],{"class":150},[118,271,154],{"class":146},[118,273,274,276,278,280,282,284,286,289,291,293,295,297,299,301,303,305],{"class":120,"line":157},[118,275,132],{"class":131},[118,277,162],{"class":135},[118,279,139],{"class":131},[118,281,167],{"class":146},[118,283,170],{"class":142},[118,285,147],{"class":146},[118,287,288],{"class":150},"'sha256'",[118,290,178],{"class":146},[118,292,181],{"class":142},[118,294,147],{"class":146},[118,296,186],{"class":150},[118,298,178],{"class":146},[118,300,191],{"class":142},[118,302,147],{"class":146},[118,304,196],{"class":150},[118,306,154],{"class":146},[118,308,309,311,313],{"class":120,"line":201},[118,310,204],{"class":146},[118,312,207],{"class":142},[118,314,210],{"class":146},[118,316,317],{"class":120,"line":213},[118,318,319],{"class":124},"\u002F\u002F Output: b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9\n",[15,321,322,324],{},[19,323,221],{},": The best general-purpose hash for most use cases in 2026.",[31,326,328],{"id":327},"sha-512","SHA-512",[36,330,331,336,341],{},[39,332,333,335],{},[19,334,90],{},": 512 bits (128 hex characters)",[39,337,338,340],{},[19,339,96],{},": 1024 bits",[39,342,343,345],{},[19,344,102],{},": Secure, useful for 64-bit platforms",[15,347,348],{},"SHA-512 operates on 1024-bit blocks and uses 80 rounds of processing. On 64-bit processors, SHA-512 can actually be faster than SHA-256 because it processes more data per block. Its longer output provides a larger security margin against future attacks.",[108,350,352],{"className":110,"code":351,"language":112,"meta":113,"style":113},"\u002F\u002F SHA-512 example (Node.js)\nconst crypto = require('crypto');\nconst hash = crypto.createHash('sha512').update('hello world').digest('hex');\nconsole.log(hash);\n\u002F\u002F Output: 309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f...\n",[115,353,354,359,375,410,418],{"__ignoreMap":113},[118,355,356],{"class":120,"line":121},[118,357,358],{"class":124},"\u002F\u002F SHA-512 example (Node.js)\n",[118,360,361,363,365,367,369,371,373],{"class":120,"line":128},[118,362,132],{"class":131},[118,364,136],{"class":135},[118,366,139],{"class":131},[118,368,143],{"class":142},[118,370,147],{"class":146},[118,372,151],{"class":150},[118,374,154],{"class":146},[118,376,377,379,381,383,385,387,389,392,394,396,398,400,402,404,406,408],{"class":120,"line":157},[118,378,132],{"class":131},[118,380,162],{"class":135},[118,382,139],{"class":131},[118,384,167],{"class":146},[118,386,170],{"class":142},[118,388,147],{"class":146},[118,390,391],{"class":150},"'sha512'",[118,393,178],{"class":146},[118,395,181],{"class":142},[118,397,147],{"class":146},[118,399,186],{"class":150},[118,401,178],{"class":146},[118,403,191],{"class":142},[118,405,147],{"class":146},[118,407,196],{"class":150},[118,409,154],{"class":146},[118,411,412,414,416],{"class":120,"line":201},[118,413,204],{"class":146},[118,415,207],{"class":142},[118,417,210],{"class":146},[118,419,420],{"class":120,"line":213},[118,421,422],{"class":124},"\u002F\u002F Output: 309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f...\n",[15,424,425,427],{},[19,426,221],{},": Use when you need maximum security margin or work primarily on 64-bit systems.",[10,429,431],{"id":430},"head-to-head-comparison","Head-to-Head Comparison",[433,434,435,451],"table",{},[436,437,438],"thead",{},[439,440,441,445,447,449],"tr",{},[442,443,444],"th",{},"Property",[442,446,83],{},[442,448,226],{},[442,450,328],{},[452,453,454,471,487,500,514,529,544,559],"tbody",{},[439,455,456,462,465,468],{},[457,458,459],"td",{},[19,460,461],{},"Output length",[457,463,464],{},"160 bits",[457,466,467],{},"256 bits",[457,469,470],{},"512 bits",[439,472,473,478,481,484],{},[457,474,475],{},[19,476,477],{},"Hex characters",[457,479,480],{},"40",[457,482,483],{},"64",[457,485,486],{},"128",[439,488,489,493,495,497],{},[457,490,491],{},[19,492,96],{},[457,494,470],{},[457,496,470],{},[457,498,499],{},"1024 bits",[439,501,502,507,510,512],{},[457,503,504],{},[19,505,506],{},"Rounds",[457,508,509],{},"80",[457,511,483],{},[457,513,509],{},[439,515,516,521,524,527],{},[457,517,518],{},[19,519,520],{},"Collision attacks",[457,522,523],{},"Broken (2017)",[457,525,526],{},"None practical",[457,528,526],{},[439,530,531,536,539,542],{},[457,532,533],{},[19,534,535],{},"Speed (64-bit)",[457,537,538],{},"Fast",[457,540,541],{},"Moderate",[457,543,538],{},[439,545,546,551,554,557],{},[457,547,548],{},[19,549,550],{},"Security level",[457,552,553],{},"0 bits",[457,555,556],{},"128 bits",[457,558,467],{},[439,560,561,566,569,572],{},[457,562,563],{},[19,564,565],{},"Best for",[457,567,568],{},"Legacy only",[457,570,571],{},"General use",[457,573,574],{},"High-security",[10,576,578],{"id":577},"understanding-collision-resistance","Understanding Collision Resistance",[15,580,581,582,585],{},"A ",[19,583,584],{},"collision"," occurs when two different inputs produce the same hash. Collision resistance means finding such pairs should be computationally infeasible.",[15,587,588,589,593],{},"The birthday paradox sets the theoretical bound: for an ",[590,591,592],"em",{},"n","-bit hash, a collision can be found in approximately 2^(n\u002F2) operations. This means:",[36,595,596,601,606],{},[39,597,598,600],{},[19,599,83],{}," (160 bits): Security level reduced to ~2^61 after attacks — practical",[39,602,603,605],{},[19,604,226],{}," (256 bits): Security level ~2^128 — no practical attack",[39,607,608,610],{},[19,609,328],{}," (512 bits): Security level ~2^256 — no practical attack",[31,612,614],{"id":613},"why-collisions-matter","Why Collisions Matter",[15,616,617],{},"If an attacker can create two documents with the same hash, they can:",[36,619,620,623,626],{},[39,621,622],{},"Forge digital signatures",[39,624,625],{},"Replace signed software with malicious versions",[39,627,628],{},"Undermine certificate authority trust chains",[15,630,631],{},"This is why SHA-1 deprecation in TLS and code signing was urgent after the SHAttered attack.",[10,633,635],{"id":634},"security-recommendations-for-2026","Security Recommendations for 2026",[31,637,639],{"id":638},"do","DO",[36,641,642,648,654,661,667],{},[39,643,644,645,647],{},"Use ",[19,646,226],{}," as your default hash function",[39,649,650,651,653],{},"Prefer ",[19,652,328],{}," for long-term archiving or high-value signatures",[39,655,656,657,660],{},"Always combine hashing with ",[19,658,659],{},"salt"," for password storage",[39,662,644,663,666],{},[19,664,665],{},"HMAC"," when you need message authentication",[39,668,669],{},"Verify hashes when downloading software or transferring files",[31,671,673],{"id":672},"do-not","DO NOT",[36,675,676,679,682,685],{},[39,677,678],{},"Use SHA-1 for any security purpose",[39,680,681],{},"Store passwords with plain SHA-256 — use Argon2id or bcrypt instead",[39,683,684],{},"Assume hash equality means file equality without considering collision risk",[39,686,687],{},"Truncate hash output without understanding the security implications",[10,689,691],{"id":690},"practical-hashing-use-cases","Practical Hashing Use Cases",[15,693,694,697],{},[19,695,696],{},"File integrity verification",": Download a file and compare its hash to the published value. Any difference means the file was corrupted or tampered with.",[15,699,700,703],{},[19,701,702],{},"Git commit identifiers",": Git uses SHA-1 (migrating to SHA-256) to identify every commit, tree, and blob. The hash uniquely represents the entire content and history.",[15,705,706,709],{},[19,707,708],{},"Blockchain",": Bitcoin uses double SHA-256 for block hashing and transaction verification. Ethereum uses Keccak-256 (SHA-3 family).",[15,711,712,715],{},[19,713,714],{},"Digital signatures",": Sign the hash of a document rather than the document itself. This keeps signatures compact regardless of document size.",[10,717,719],{"id":718},"related-guides","Related Guides",[36,721,722,729,735],{},[39,723,724],{},[725,726,728],"a",{"href":727},"\u002Fguides\u002Fsha-256-practical-guide","SHA-256 Practical Guide",[39,730,731],{},[725,732,734],{"href":733},"\u002Fguides\u002Fhashing-vs-encryption","Hashing vs Encryption",[39,736,737],{},[725,738,740],{"href":739},"\u002Fguides\u002Fbase64-vs-encryption","Base64 vs Encryption",[10,742,744],{"id":743},"try-it-yourself","Try It Yourself",[15,746,747,748,752],{},"Curious how different inputs produce different hashes? Our free ",[725,749,751],{"href":750},"\u002Ftools\u002Fhash-calculator","Hash Calculator"," lets you compute SHA-1, SHA-256, and SHA-512 hashes instantly in your browser. No data leaves your device — all calculations run locally using the Web Crypto API.",[15,754,755],{},"Test it now: change a single letter in your input and watch the entire hash transform. That is the avalanche effect in action.",[15,757,758],{},[725,759,760],{"href":750},"Calculate hashes now →",[762,763,764],"style",{},"html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}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":113,"searchDepth":128,"depth":128,"links":766},[767,770,775,776,779,783,784,785],{"id":12,"depth":128,"text":13,"children":768},[769],{"id":33,"depth":157,"text":34},{"id":71,"depth":128,"text":72,"children":771},[772,773,774],{"id":82,"depth":157,"text":83},{"id":225,"depth":157,"text":226},{"id":327,"depth":157,"text":328},{"id":430,"depth":128,"text":431},{"id":577,"depth":128,"text":578,"children":777},[778],{"id":613,"depth":157,"text":614},{"id":634,"depth":128,"text":635,"children":780},[781,782],{"id":638,"depth":157,"text":639},{"id":672,"depth":157,"text":673},{"id":690,"depth":128,"text":691},{"id":718,"depth":128,"text":719},{"id":743,"depth":128,"text":744},"2026-05-27","Understand how hashing algorithms work. Compare SHA-1, SHA-256, and SHA-512 with practical examples and security considerations.","md",{"immutable":790},true,"\u002Fguides\u002Fhashing-algorithms-explained",6,{"title":5,"description":787},"guides\u002Fhashing-algorithms-explained","1ynnOJ1GGE6aFCNVhyrz-D97MM5KL4wBJCCkXEazdNE",1780401324942]