Hashing
Cryptographic hashing generates a fixed-length digest from input data of any size, with determinism, non-invertibility, and collision resistance properties, enabling data integrity and authentication.
A cryptographic [[hash function](/en/terms/hash-function)](/en/terms/cryptographic-hash-function) takes an input of arbitrary length and returns a fixed-length digest. It is characterized by determinism, fixed output size, and one-wayness. In addition to being deterministic and of fixed length, cryptographic hash functions aim to provide preimage resistance (given a digest, finding a preimage is infeasible), second-preimage resistance (a different input with the same digest is infeasible), and collision resistance (hard to find two inputs that collide). They are designed to be efficient to compute, and the output digest should exhibit the avalanche effect: a small change in input yields a significantly different digest. They are used in data integrity checks, digital signatures, and password hashing when appropriate. Note: a nonce is not a property of the hash function itself; it may be used in protocols to salt or vary hashing contexts, but is not part of the hash function core property.
graph LR
Center["Hashing"]:::main
Rel_iteration["iteration"]:::related -.-> Center
click Rel_iteration "/terms/iteration"
Rel_hash_function["hash-function"]:::related -.-> Center
click Rel_hash_function "/terms/hash-function"
Rel_consensus_mechanism["consensus-mechanism"]:::related -.-> Center
click Rel_consensus_mechanism "/terms/consensus-mechanism"
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
Hashing is like making a smoothie out of a fruit. You can easily turn a strawberry into a smoothie, but there's no way to turn the smoothie back into a strawberry. Also, a single strawberry will always make the exact same smoothie!
🤓 Expert Deep Dive
## The Significance of SHA-256
SHA-256 is the beating heart of the Bitcoin network. It is used to create the linked 'chain' by including the previous block's hash in the current block, and it powers the Proof-of-Work mining system where miners compete to find a specific hash. Its 256-bit output provides 128-bit 'collision security,' which remains strong even against the most advanced classical computers.