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 →
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.
- 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.
- compression functionuses · A compression function is a function that transforms input information into a shorter or fixed-size representation.
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.

