Foundations & cryptography

cryptographic hash

A cryptographic hash is a function that takes any data — a word, a file, an entire library — and crunches it down to a short, fixed-length string of characters that acts as its digital fingerprint. The same input always produces the same fingerprint, but even a one-character change to the input scrambles the output completely. Think of it as a tamper-evident wax seal: open or alter the contents and the seal no longer matches.

Two properties make it useful for security. It is one-way: from the fingerprint alone you cannot work backwards to recover the original data, so the function is easy to run forwards but practically impossible to reverse. And it is collision-resistant: it is infeasible to find two different inputs that produce the same fingerprint. Together these mean a hash can stand in for the data as a compact, trustworthy summary — if two hashes match, the data is the same; if they differ, something changed.

This is the glue that holds a blockchain together. Each block is summarized by its hash, and each new block includes the hash of the one before it, so the whole history is locked into a tamper-evident order. Hashes also let a network compare huge datasets by checking a few short strings instead of every byte, which is why they show up everywhere from password storage to file verification.

hash("Pay Alice 5")  -> 9f86d081...4e3a
hash("Pay Alice 6")  -> b1f3c0a7...d29c
(one digit changed -> a totally different fingerprint)

A tiny change in the input produces a wholly different hash — that is how tampering is caught.

Bitcoin uses a hash function called SHA-256; the name refers to the 256-bit (about 64-character) fingerprint it always produces, no matter how big the input.

Also called
hash function哈希散列雜湊