Cryptographic hash functions · 04 Worked example

Hash functions: worked example

SHA-256 values of similar words and phrases, to see the avalanche effect, and the official test vectors.

The standard’s documents give test values that anyone can verify. For SHA-256:

terminale
SHA-256("abc") = ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad
SHA-256("")    = e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

The second line is the value of an empty file: those who work with hash values learn to recognise it, because it immediately signals that a file contains no data.

The avalanche effect

Try computing the values of “abc” and “abd”. The two strings differ by a single letter, that is by two bits; the values have nothing in common that can be recognised by eye. There is no “closeness” between values that reflects closeness between messages.

InputLengthSHA-256 value length
One letter1 byte256 bits
A novelabout 1 MB256 bits
A disk2 TB256 bits
Continue with
05 Weaknesses and attacks

Hash functions: weaknesses and attacks

MD5 and SHA-1 collisions, chosen-prefix attacks, length extension and precomputed tables for passwords.

↑