Hash Function
A mathematical function that converts an input of any length into a fixed-size string of characters, which is typically a numbers-and-letters sequence.
A hash function takes an input (like a word or a 1GB video) and produces a unique, fixed-length string of characters (e.g., 256 bits). It is the bedrock of data integrity. If even a single character in the input is changed, the entire hash changes completely (Avalanche Effect). This allows blockchains to verify headers and transactions in a lightweight way without checking the entire dataset every time.
🛡️ Trust Score
✅ Verified Technical Facts
- • A hash function maps input of any size to an output of a fixed size.
- • Cryptographic hash functions are one-way (irreversible).
- • A small change in input leads to a large change in output (Avalanche Effect).
- • Determinism means the same input always produces the same hash.
- • Collision resistance means it's hard to find two different inputs with the same hash.
- • SHA-256 is the hash function used in Bitcoin's Proof of Work.
graph LR
Center["Hash Function"]:::main
Pre_cryptography["cryptography"]:::pre --> Center
click Pre_cryptography "/terms/cryptography"
Pre_mathematics["mathematics"]:::pre --> Center
click Pre_mathematics "/terms/mathematics"
Rel_merkle_tree["merkle-tree"]:::related -.-> Center
click Rel_merkle_tree "/terms/merkle-tree"
Rel_digital_signature["digital-signature"]:::related -.-> Center
click Rel_digital_signature "/terms/digital-signature"
Rel_proof_of_work["proof-of-work"]:::related -.-> Center
click Rel_proof_of_work "/terms/proof-of-work"
classDef main fill:#7c3aed,stroke:#8b5cf6,stroke-width:2px,color:white,font-weight:bold,rx:5,ry:5;
classDef pre fill:#0f172a,stroke:#3b82f6,color:#94a3b8,rx:5,ry:5;
classDef child fill:#0f172a,stroke:#10b981,color:#94a3b8,rx:5,ry:5;
classDef related fill:#0f172a,stroke:#8b5cf6,stroke-dasharray: 5 5,color:#94a3b8,rx:5,ry:5;
linkStyle default stroke:#4b5563,stroke-width:2px;
🧠 Knowledge Check
🧒 Explain Like I'm 5
Fingerprint Machine 🕵️♂️ Imagine a magic machine where you can put in *anything*—a letter, a book, or even a whole library—and it spits out a unique sticker with a short code on it. If you put the exact same book in again, you get the exact same sticker. But if you tear out just *one tiny page* and put the book in, the sticker code changes completely. You can't look at the sticker and recreate the book (it's one-way), but you can use the sticker to prove that the book hasn't been changed.
🤓 Expert Deep Dive
Cryptographic hash functions must satisfy three main properties. Pre-image resistance: Given a hash $h$, it's computationally infeasible to find input $m$ such that $hash(m) = h$. Second pre-image resistance: Given $m1$, it's hard to find $m2$ such that $hash(m1) = hash(m2)$. Collision resistance: It's hard to find any two different inputs $m1, m2$ that produce the same hash. The Birthday Paradox defines the security level against collisions; for a 256-bit hash, the security level is 128 bits. The Avalanche Effect ensures that even a one-bit change in input flips roughly 50% of the output bits, preventing pattern recognition.