What Is a Hash Function? Cryptographic Hashing Explained
A cryptographic hash function maps input data of any size to a fixed-length output (the digest or hash). The same input always produces the same output, but a tiny change in input produces a completely different hash (avalanche effect). Hash functions are one-way: it is computationally infeasible to reverse a hash back to its input.
Essential Properties
Deterministic: same input always gives the same output. Pre-image resistance: given a hash H, it is infeasible to find an input X such that hash(X) = H. Second pre-image resistance: given X and hash(X), it is infeasible to find Y ≠ X with the same hash. Collision resistance: it is infeasible to find any two inputs X ≠ Y where hash(X) = hash(Y). MD5 and SHA-1 have broken collision resistance; use SHA-256 or SHA-3.
Common Hash Algorithms
MD5 (128-bit): fast but cryptographically broken — collisions constructible in seconds. SHA-1 (160-bit): deprecated, collision found in 2017. SHA-256 (256-bit): part of SHA-2 family, currently secure, widely used in TLS and bitcoin. SHA-3 (Keccak): structurally different from SHA-2, provides an independent security assumption. BLAKE3: very fast, modern design, suitable for checksums and non-cryptographic uses.
Use Cases
Data integrity: compare the SHA-256 of a downloaded file against the published checksum. Password storage: bcrypt/Argon2 use hashing with salt and work factor (not SHA directly). Digital signatures: sign the hash of a document, not the document itself. Blockchains: Bitcoin blocks include the SHA-256d hash of the previous block header, chaining them. Content addressing: IPFS and Git identify objects by their hash.