Troubleshooting your MD5 implementation
Introduction
This is a list of MD5 hashes of an empty string (""
) computed with various buggy implementations, with descriptions of the bugs.
(The correct hash is d41d8cd98f00b204e9800998ecf8427e
.)
Reversed byte order in 32-bit integers
- initial state constants:
d67dfb7e907840deee15560e9657e40f
- sine constants:
af9d47553364d9f47b6eb4ba2867777e
- unpacking the message into integers:
487f7b22f68312d2c1bbc93b1aea445b
- packing the integers into hash:
d98c1dd404b2008f980980e97e42f8ec
- both initial state & sines:
97a6a5c2732be6b7e01908d4fc508a35
- both unpacking & packing:
227b7f48d21283f63bc9bbc15b44ea1a
- all (initial state, sines, packing & unpacking):
77e9629e06143371ebeef58872a2a66a
Forgot the bit rotation or an addition
68f1aa18c4f40f2e127d4a3a1ef19cbd
85e950ba1c2a2ab552571aa19fa59660
900d850bf8aa2478bf22ac013911db80
ac1d1f03d08ea56eb767ab1f91773174
ad4aada3dc19a43f1df86ee9863522a1
Wrong order of bit rotation and additions
16bf63e408d611b7473b6f2bdfa81f3c
200bd64b18e70eb87b12380986ad1e5b
270846620e2b7a2255caf3aa58328a92
32af135b718dbc3e32dbd2f8d8b3be1e
829a5cde6dcb2f2527abe5e59260a378
87ca40e6cbef09be6c4d03ffbaf6d770
89353b2863cddf94911af9eb10d2dd85
8ec20bc6dfacfc6f306ceb03bcc834b6
a16b08603198ebb82e79415822c5177b
c04c1fb6228bd95d938dc90c60104db6
d2d8723d4b0f4c632931a02fd129fdcd
d5f7e51814fe79c75724765102769d15
dcd1f5e2222869a4b2f334abdaa9361e
e8f46c7d3edb477ed6e7dde3c2b377af
ee074047c10acd2018701d2fa8d8d517
Wrong precedence of XOR vs. AND/OR
045a33e12fb88967a7eb35a4bd916244
1a9714b93e70bfb5b68683723067fb90
220e5c21618335b02415830eab9cef00
26ea77c119f2b441b885583b88086105
28e628a6f2a7e75042dcbe54e19bcbb1
291b3a705a88977a25957737e56024d5
2b21229104500c83511a6b434247bca5
3719b8e1dc4282dae5a4a3b614476f74
3c55d6019cc0fefa0e3309c12e48d6d4
3d47a045652948f7c3bb63051734408b
5d7bb1f3cf36e93b7cefebdd936bb341
6a985978ac5b3273d60a178345f53d74
72efc54eaf7b094f34e96dfed0855b1a
8000e254579b10585b83c1c1009781a4
83f9fa8ee65d5876ca0b5b6e12a6244d
ad4fb1dff317a70403488d93c8f277be
b0444f0f8aad55adb337a57e73c6a1bf
be5894d2c520552a94d93c6bbf96ffcb
c63ac266aab86e3634bf7d72c7f36dff
c7160a5a0c78e5bd0d31f15939c60183
c71d4b400f6f7b910f931ad583715627
d0a6f2fd2fb7f06c22200e8e7674c683
e4f37f43c04ebe1a4323e6da185fa55d
e63e5b2b46f589e461bf326ffc8d08eb
ec4d7375028ac4b7b01bce7be63b738e
fc40018a3492e9c7ed935ed91cc1ddd2
State of algorithm shuffled incorrectly
14f64bf678f2b950fcb97531eca86420
242c7db412579bdffcb97531eca86420
27373a84908b6f0e83a54852eca86420
2b372c6b12579bdffcb97531731e3b1d
2ff00738ffffffff878888887431eda8
45f7ccbd4260425f9ee4e36d122a1cd5
4aa375120db939987555c138ac85757e
4bff3733cb077a1c025c4188625e3c82
5cc21fb812579bdffcb975311293dec6
7883280312579bdf70120f6deca86420
88b0e5a212579bdf73fba873792f38a0
8f4e91d640a24a357bc1b612eca86420
97ec2cfa54a61e87fcb97531eacdd686
9d60223f8744553ffcb97531b7bd95cd
9ea7fa2612579bdffcb97531eca86420
a3557d5c12579bdf05a85695eca86420
ab8773f8571b483c5b840106a9318bfc
ace1d231878888887431eda8ffffffff
aed5854b12579bdffcb97531eca86420
b8c7d5aa15970fa61f4674134c0a3108
c53910a3d6be8d64fcb97531eca86420
dd7a4aa712579bdffcb97531eca86420
f2d4968712579bdfa64945898a3cf089
Miscellaneous issues
- forgot to append
0x80
to the message:ac1d1f03d08ea56eb767ab1f91773174
- range 0–63 instead of 1–64 in sine constants:
a75646c5368368506ef66450a799875a
- degrees instead of radians in sine constants:
1da3aaa59fa0de764774f501a73dd073
- shifted left instead of rotating left:
9a4b397d22a4a8dc97d5951b0f4df0f9
- 8-bit addition instead of 32-bit:
98e800af1dc6345251bbc090ccb5eaa6
- 16-bit addition instead of 32-bit:
a8bb05547769f4d59a50cee3aa0a0aa2
- bit operations for first 16 rounds used for all rounds:
5d3be1a88fe3e9b6c349de8700d978e5