Merkle–Damgård construction
The Merkle–Damgård construction builds an arbitrary-length hash function by iteratively applying a fixed-size compression function to padded message blocks.
Hacking Cryptography
A hash function built by repeatedly applying a compression function to message blocks in the Merkle–Damgård construction.
- How it is used
- Explains why familiar hash functions process blocks iteratively and why that structure matters for authentication failures.
- How deep it goes
- Traces padding, chained compression, exposed final state, and a SHA-256 length-extension exploit without detailing compression-function internals.
- Examples
- Demonstrates chained message blocks and a forged bank transaction request that extends a SHA-256 secret-prefix MAC.
- What you can do after
- Evaluate/understand why a published Merkle–Damgård digest can enable extension of secret-prefix MAC inputs.
Read how Hacking Cryptography explains Merkle–Damgård construction →
Real-World Cryptography
The Merkle–Damgård construction builds an arbitrary-length hash function by iteratively applying a fixed-size compression function to padded message blocks.
- How it is used
- Explains how SHA-2 hashes arbitrary-length messages using repeated fixed-size compression calls.
- How deep it goes
- Defines padding, blocking, and chaining, but treats the compression function as a black box.
- Examples
- Uses SHA-256’s 512-bit blocks, block-processing diagrams, and OpenSSL digest commands for SHA-2 variants.
- What you can do after
- Evaluate/understand how fixed-size compression supports arbitrary-length hashing and where collision resistance comes from.
Read how Real-World Cryptography explains Merkle–Damgård construction →
What to know first
- hash functionA hash function is a deterministic function that maps input data to a hash value, typically of fixed size, for uses such as lookup, indexing, comparison, or integrity checking.
Related concepts
- SHA-2includes · SHA-2 is a standardized family of cryptographic hash algorithms that produces fixed-length digests, including SHA-224, SHA-256, SHA-384, and SHA-512.
- compression functionhas part · A compression function is a function that transforms input information into a shorter or fixed-size representation.
- md5implemented by · MD5 is a cryptographic hash algorithm that produces a 128-bit message digest and is considered insecure because practical collision attacks exist.
- SHA-1implemented by · SHA-1 is a cryptographic hash algorithm that produces a 160-bit digest and is no longer considered collision-resistant because practical collision attacks exist.
- sponge constructioncontrasts with · A sponge construction absorbs input into a state through repeated permutation applications and squeezes output from that state, supporting outputs of arbitrary length.
Questions about Merkle–Damgård construction
What is Merkle–Damgård construction?
The Merkle–Damgård construction builds an arbitrary-length hash function by iteratively applying a fixed-size compression function to padded message blocks.
Which Manning books explain Merkle–Damgård construction?
Hacking Cryptography and Real-World Cryptography.
What should I know before learning Merkle–Damgård construction?
Manning books that teach Merkle–Damgård construction usually introduce hash function first.
What is the difference between Merkle–Damgård construction and sponge construction?
The Merkle–Damgård construction builds an arbitrary-length hash function by iteratively applying a fixed-size compression function to padded message blocks. A sponge construction absorbs input into a state through repeated permutation applications and squeezes output from that state, supporting outputs of arbitrary length.
What kinds of Merkle–Damgård construction are there?
Kinds of Merkle–Damgård construction include SHA-2.
What are the parts of Merkle–Damgård construction?
Merkle–Damgård construction includes compression function and message block.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

