Principles · Overview

Cryptographic hash functions: the fingerprint of data

What cryptographic hash functions are, the properties they must have, the birthday paradox, the history from MD5 to SHA-3, known attacks and today’s uses, from signatures to blockchain.

A cryptographic hash function takes as input data of any size — a word, a book, an entire disk — and returns a fixed-length string, called a hash value or digest. The same input always gives the same value; a minimal change produces a completely different value; and the data cannot be recovered from the value.

They are among the least visible and most used tools of cryptography. They protect passwords in websites’ databases, guarantee that a downloaded file has not been altered, are at the heart of digital signatures and certificates, hold together the blocks of a blockchain and make it possible to prove in court that digital evidence has not changed.

256bits: the length of a SHA-256 hash value
2^128attempts, roughly, to find a collision on a 256-bit value, because of the birthday paradox
2017the year the first practical SHA-1 collision was published

The required properties

Determinism
The same data always produce the same value.
Efficiency
The value is computed quickly even for large amounts of data.
Preimage resistance
Given a value, it is infeasible to find data that produce it.
Second-preimage resistance
Given a message, it is infeasible to find another with the same value.
Collision resistance
It is infeasible to find any two messages with the same value.
Avalanche effect
Changing one input bit changes on average half the bits of the value.

For the use of hash values in investigations see digital forensics; here we explore how they work. Hash functions are the basis of HMAC, digital signatures and the algorithms for password storage.

↑