What Is the Avalanche Effect?
If you make just a tiny change to the input of a cryptographic hash function, the resulting hash value can change dramatically.
This exact behavior is described by the avalanche effect.
A simple example:
Hello World
and:
hello World
The two texts differ by only a single letter: an uppercase H became a lowercase h.
If we calculate the SHA-256 hash for both texts, we get:
Hello World
a591a6d40bf420404a011733cfb7b190d62c65bf0bcda32b57b277d9ad9f146e
and:
hello World
db4067cec62c58bf8b2f8982071e77c082da9e00924bf3631f3b024fa54e7d7e
Even though the inputs barely differ, the two hash values look completely different.
That's no coincidence — it's an important property in the design of cryptographic hash functions.
What a hash function fundamentally does is explained in the article What Is a Hash Function?.
What Does Avalanche Effect Mean?
Simplified, the term describes the following behavior:
A small change to the input leads to a large change in the output.
With the avalanche effect, we're particularly interested in what happens when a single bit of the input is changed.
With good avalanche behavior, you'd expect on average roughly half of the output bits to change.
For SHA-256, the output consists of 256 bits.
That means:
256 × 0.5 = 128
Across many such comparisons, you'd therefore expect on average roughly 128 changed bits.
The key word here is on average.
The avalanche effect doesn't mean that exactly 128 of the 256 bits must flip with every single change.
This Example Really Only Changes One Bit
With:
Hello World
and:
hello World
visibly, one character was changed.
Interestingly, H and h actually differ by only a single bit in their ASCII and UTF-8 representation.
H = 01001000
h = 01101000
↑
So this example isn't just a change of a single character — it's actually a single-bit flip in the input.
That makes it especially well suited for demonstrating the avalanche effect.
Try the Avalanche Effect Yourself
The easiest way to understand the effect is to try it yourself.
Change just one letter, one number, or one space in either input.
Avalanche Effect
Even a minimal change to the input — here just a single letter — causes SHA-256 to produce a completely different hash. This is called the avalanche effect.
With an ideal avalanche effect, on average around 50 % of the bits differ — measured across many inputs. That's a statistical average, not a guarantee for any single change.
You can also find this tool in the tools section.
The component calculates both SHA-256 hash values directly in your browser and then compares all 256 bits with each other.
For:
Hello World
hello World
124 of 256 bits differ.
That corresponds to:
124 / 256 × 100
≈ 48.4%
So changing just one input bit here causes almost half of the entire hash value to change.
This single example illustrates the avalanche effect. It isn't, however, proof of the cryptographic quality of SHA-256. For that, the behavior would have to be examined systematically across many inputs and bit changes.
What Actually Changes?
We usually see hash values as hexadecimal representation:
a591a6d40bf420404a011733cfb7b190d...
The SHA-256 hash value, however, consists of 256 bits.
One hex character represents four bits.
That's why:
256 bits
÷ 4
= 64 hex characters
A complete SHA-256 hash is therefore normally represented as 64 hex characters.
When I talk about changed bits in the context of the avalanche effect, I'm not simply comparing the visible hex characters of the two hash values.
Instead, the actual 256 bits are compared with each other.
For each position, we check:
Bit A = Bit B?
or:
Bit A ≠ Bit B?
We can then count how many of the 256 positions differ.
That's exactly what the interactive demonstration above does.
Why Roughly 50 Percent?
With the avalanche effect, a small change to the input should be spread as broadly as possible across the output.
If you change a single input bit, with good avalanche behavior on average roughly half of the output bits should change.
For a 256-bit hash, that corresponds on average to:
256 × 0.5
= 128
changed bits.
The 50 percent figure is a statistical expectation over many observations, not a fixed requirement for any single hash comparison.
The Strict Avalanche Criterion
A related, stricter property is the strict avalanche criterion, or SAC for short. It was introduced by Webster and Tavares in their work on the design of S-boxes and distinguishes the avalanche effect from a stricter, bit-by-bit requirement.
Simplified, the SAC requires that each individual output bit changes with a probability of 50 percent when a single input bit is changed.
So there are two statements worth distinguishing:
Avalanche effect:
When an input bit is changed, on average roughly half of the output bits change.
Strict avalanche criterion:
Each individual output bit changes with a probability of 1/2 for such a bit flip.
The two concepts are closely related, but they're not identical.
Why Isn't It Always Exactly 50 Percent?
In this example, 124 of 256 bits change.
That's roughly 48.4 percent.
For other inputs, it might be 121, 130, or 136 bits.
That doesn't contradict the avalanche effect.
You can think of it similarly to flipping a coin many times.
If you flip a fair coin ten times, you don't need to get exactly five heads and five tails.
Across many trials, though, the underlying statistical behavior becomes visible.
Likewise, the avalanche effect isn't about hitting exactly 50 percent for any single example.
What matters is the behavior across many different inputs and bit changes.
A Small Change Propagates Through the Calculation
The name avalanche effect describes this behavior vividly.
A small change triggers a kind of avalanche:
small change
↓
processing by the hash function
↓
changes spread out
↓
many changed output bits
SHA-256 processes the input in blocks and transforms it through multiple processing steps and rounds.
Intermediate results, in turn, influence later calculations.
A change to the input can therefore propagate through the rest of the calculation and ultimately affect many bits of the resulting hash value.
Why Is the Avalanche Effect Important?
Imagine a poorly constructed hash function where a small change to the input only causes a small, systematic change to the hash value.
For cryptographic hash functions, you want to avoid such simple, local relationships.
A small change should instead spread widely across the output.
The avalanche effect is therefore an important property in the design of cryptographic functions.
On its own, though, it doesn't prove that a hash function is cryptographically secure.
A hash function can show good avalanche behavior and still have other cryptographic weaknesses.
Avalanche Effect Doesn't Mean Randomness
If two SHA-256 hash values look completely different, you might suspect that SHA-256 produces random results.
That's not the case, though.
SHA-256 is deterministic.
That means:
same input
+
same algorithm
=
same hash value
Always.
If you calculate the SHA-256 hash of:
Hello World
today and use exactly the same input again tomorrow, you get the same hash value.
The avalanche effect therefore doesn't mean the hash function works randomly.
The output changes drastically with small changes to the input, even though the calculation itself is completely deterministic.
What determinism and other fundamental properties of hash functions mean is explained in more detail in the article What Is a Hash Function?.
Avalanche Effect Is Not Collision Resistance
Another important distinction concerns hash collisions.
The avalanche effect describes how much the hash value changes when the input changes.
Collision resistance, on the other hand, deals with a different question:
How difficult is it to find two different inputs that produce the same hash value?
Those are two different properties.
Good avalanche behavior therefore doesn't automatically mean a hash function is sufficiently collision-resistant.
What a hash collision is, and why collisions are mathematically unavoidable for hash functions, is explained in detail in the article What Is a Hash Collision?.
Can You Measure the Avalanche Effect?
Yes.
A simple demonstration involves:
- generating an input,
- changing exactly one bit of the input,
- calculating both hash values,
- counting the differing output bits.
For SHA-256, you then get a value between 0 and 256 differing bits.
The percentage difference can be calculated with:
differing bits
──────────────── × 100
256
For this example:
124
─── × 100
256
that gives:
48.4375%
rounded:
48.4%
A single such value, however, isn't enough to judge the quality of a hash function.
That would require systematically examining the behavior across many different inputs and bit changes.
The demonstration on this page is meant primarily to make visible what's meant by the avalanche effect.
Is a Higher Percentage Automatically Better?
No.
If, for example, 70 percent of the bits differ in a comparison, that doesn't automatically mean this result is better than one with 51 percent.
The desired behavior isn't to change as many bits as possible.
That's why you shouldn't read the demonstration's percentage as a quality score:
48% = bad
50% = perfect
70% = especially secure
That's not how the avalanche effect works.
The displayed value merely describes the specific difference between the two hash values just calculated.
The Key Takeaways
The avalanche effect describes how much the output of a cryptographic function changes with a small change to the input.
The most important points:
- Changing even a single input bit can change many bits of the hash value.
- With good avalanche behavior, you'd expect roughly 50 percent changed output bits across many observations.
- For SHA-256, that would be on average roughly 128 of 256 bits.
- For any single comparison, it doesn't have to be exactly 128 bits.
- The comparison happens at the bit level, not based on the visible hex characters.
- The strict avalanche criterion is a stronger, related requirement on individual output bits.
- SHA-256 remains deterministic despite the avalanche effect.
- Avalanche effect and collision resistance are different properties.
- Good avalanche behavior alone doesn't prove the cryptographic security of a hash function.
The avalanche effect thus makes an important property of cryptographic hash functions visible:
A tiny change at the start can propagate through the entire calculation and ultimately produce a drastically different hash value.
Where To Go From Here
With hash functions, hash collisions, and the avalanche effect, some important fundamentals are now in place.
Next, you can take a closer look at:
- What Is Preimage Resistance?
- What Is Second-Preimage Resistance?
- What Is Collision Resistance?
- How Does SHA-256 Work?
- The Birthday Paradox
- Why is MD5 insecure?
- Why is SHA-1 considered insecure?
Sources and Standards
The following primary and standards sources form the basis for the technical statements in this article:
-
National Institute of Standards and Technology (NIST), FIPS 180-4 – Secure Hash Standard (SHS) Official specification of SHA-256 and the SHA-2 family.
-
National Institute of Standards and Technology (NIST), Hash Functions Overview of cryptographic hash functions and their security properties.
-
A. F. Webster, S. E. Tavares, On the Design of S-Boxes, CRYPTO '85. Scientific work examining the avalanche effect and introducing the strict avalanche criterion.