Cryptographic Hash
Also known as: hash function, digest, checksum, SHA-256.
A function that turns any input into a short fixed-size fingerprint: the same bytes always give the same fingerprint, and any change gives an unrelated one.
Synthetic dataExamples on this page use synthetic data created for illustration.
Definition
A cryptographic hash function turns any input into a short, fixed-size fingerprint. The same input always gives the same fingerprint, a tiny change gives a completely different one, and it is practically impossible to find two different inputs with the same fingerprint.
In plain terms
Think of a fingerprint for data. You can compute it quickly, compare two fingerprints to see whether two files are identical, and store the fingerprint instead of the file when all you need is to detect change. You cannot rebuild the data from the fingerprint, and you cannot craft a different file that matches it.
The fingerprint is of bytes, not of meaning. Two texts that mean the same thing but are written differently (an extra zero, a different line ending) have different fingerprints, which is why systems that hash data first agree on one canonical way of writing it.
Example
SHA-256 of three texts (first 12 hex characters shown):
| Text | Fingerprint |
|---|---|
19.99 | 2b8216946cd1… |
19.99 (again) | 2b8216946cd1… |
19.990 (same number, one more digit) | f94da8bfd047… |
The last two mean the same price but have unrelated fingerprints. A pipeline that hashes records must first write every number in one agreed form, or identical data will look different.
Common misunderstandings
- “A hash can be reversed.” It cannot be computed backwards, but a short or guessable input (a common password) can be found by trying candidates.
- “Equal values give equal hashes.” Only equal bytes do; formatting differences change the hash.
- “Any hash function will do for integrity.” MD5 and SHA-1 have known collision attacks; use a current function such as SHA-256.
References
- FIPS PUB 180-4: Secure Hash Standard (SHS) . NIST, 2015.
- Niels Ferguson, Bruce Schneier, Tadayoshi Kohno. Cryptography Engineering . Wiley, 2010. ISBN 978-0470474242.