Change one bit and compare two SHA-256 fingerprints

A one-bit edit can change many bits in a SHA-256 fingerprint. The fingerprint still takes up 256 bits.

The example below compares the original byte with a copy that differs at one bit.

One changed input bit, many changed output bits

In Lesson 1.2, you compared fingerprints to see whether a note had changed. Here the hash function is SHA-256. In Lesson 3.1, the letter A had byte 01000001. Flip its rightmost bit, bit 8 from the left, and you get 01000000, the byte for @.

A one-bit change from A to @
ByteFull digest (hex)
A559aead08264d5795d3909718cdd05abd49572e84fe55590eef31a88a08fdffd
@c3641f8544d7c02f3580b07c0f9887f0c6a27ff5ab1d4a3e29caf197cfc299ae

The digests differ in 136 bit positions, just over half of the 256 bits. SHA-256 mixes input information across its output, so a change at one input position can affect many digest positions. The count varies with the input and the bit you flip. A hex digit stands for four bits. For example, changing 0 (0000) to f (1111) changes one hex digit and four bits.

The length stays fixed

The digest length is the number of bits the hash function returns. SHA-256 gives 256 output bits for each input it accepts, displayed here as 64 hex digits. It is deterministic. Put the original byte back and the digest goes back to exactly the same value. See NIST’s Secure Hash Standard.

Check your understanding

A friend flips a different input bit and predicts that only one digest bit will change. What would you tell them to expect, and what must stay fixed?

Show the answer

Many output bits can change. SHA-256 still returns 256 bits, or 64 hex digits.