Debugging a MD5 Implementation

Craig Buchanan

Craig Buchanan / January 08, 2023

A tricky part of implementing a secure hash algorithm is debugging where the purposely-opaque algorithm may have gone wrong. For that reason, I have put together the result of each MD5 step for several sample inputs. If you are having trouble debugging your MD5 implementation, I hope this helps!

InputMD5 Hash Result
d41d8cd98f00b204e9800998ecf8427e
message digestf96b697d7cb7938d525a2f31aaf161d0
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789d174ab98d277d9f5a5611c2c9f419d9f
1234567890123456789012345678901234567890123456789012345678901234567890123456789057edf4a22be3c955ac49da2e2107b67a

Empty String

Input

Preprocessed

00000080 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000

Steps

Stepabcd
067452301efcdab8998badcfe10325476
110325476a5202774efcdab8998badcfe
298badcfef59592dda5202774efcdab89
3efcdab89e7f06b23f59592dda5202774
4a52027741b163203e7f06b23f59592dd
5f59592dd320333441b163203e7f06b23
6e7f06b232f35d494320333441b163203
71b163203f5b158db2f35d49432033344
8320333449bc13ce9f5b158db2f35d494
92f35d4943893b9919bc13ce9f5b158db
10f5b158dbfce4a3123893b9919bc13ce9
119bc13ce9e1ef0576fce4a3123893b991
123893b99170768a29e1ef0576fce4a312
13fce4a312f56c7cf170768a29e1ef0576
14e1ef0576374943a7f56c7cf170768a29
1570768a295aa53f75374943a7f56c7cf1
16f56c7cf1d6819c6a5aa53f75374943a7
17374943a71c7d7513d6819c6a5aa53f75
185aa53f757bd57a3a1c7d7513d6819c6a
19d6819c6ac095f13a7bd57a3a1c7d7513
201c7d7513bd782e17c095f13a7bd57a3a
217bd57a3a3d1e3e6cbd782e17c095f13a
22c095f13a68b7b3e33d1e3e6cbd782e17
23bd782e17eb41643e68b7b3e33d1e3e6c
243d1e3e6ce422531aeb41643e68b7b3e3
2568b7b3e3306ec122e422531aeb41643e
26eb41643ed28c77c2306ec122e422531a
27e422531aa3c663dad28c77c2306ec122
28306ec122a0572807a3c663dad28c77c2
29d28c77c213707036a0572807a3c663da
30a3c663daae7813db13707036a0572807
31a05728071c31c384ae7813db13707036
3213707036a2205f1f1c31c384ae7813db
33ae7813dbdf63eaa1a2205f1f1c31c384
341c31c384c3689f5bdf63eaa1a2205f1f
35a2205f1f12f3e755c3689f5bdf63eaa1
36df63eaa1004b666912f3e755c3689f5b
37c3689f5b5f7a9b2e004b666912f3e755
3812f3e755abc34e165f7a9b2e004b6669
39004b666991ca4cb7abc34e165f7a9b2e
405f7a9b2ec5dc8c1591ca4cb7abc34e16
41abc34e164497169dc5dc8c1591ca4cb7
4291ca4cb776fd93d44497169dc5dc8c15
43c5dc8c15fd95f24376fd93d44497169d
444497169d0fe32453fd95f24376fd93d4
4576fd93d43f55edfd0fe32453fd95f243
46fd95f24322a31f543f55edfd0fe32453
470fe3245368d84ea222a31f543f55edfd
483f55edfdca7d2dbd68d84ea222a31f54
4922a31f5493aa2577ca7d2dbd68d84ea2
5068d84ea21688dc8593aa2577ca7d2dbd
51ca7d2dbdcd85b8cb1688dc8593aa2577
5293aa2577561e0689cd85b8cb1688dc85
531688dc855625a114561e0689cd85b8cb
54cd85b8cb3450f42b5625a114561e0689
55561e0689392ad0d03450f42b5625a114
565625a1141e77fa61392ad0d03450f42b
573450f42b474a9c8c1e77fa61392ad0d0
58392ad0d0dfce00bc474a9c8c1e77fa61
591e77fa6136594b14dfce00bc474a9c8c
60474a9c8c3013018236594b14dfce00bc
61dfce00bc7246fad33013018236594b14
6236594b146e10a4767246fad330130182
6330130182ff4ea3eb6e10a4767246fad3
647246fad314e45506ff4ea3eb6e10a476

Result

d41d8cd98f00b204e9800998ecf8427e

Small string

Input

message digest

Preprocessed

7373656d 20656761 65676964 00807473
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000070 00000000

Steps

Stepabcd
067452301efcdab8998badcfe10325476
1103254765ed29daeefcdab8998badcfe
298badcfee2a2fc325ed29daeefcdab89
3efcdab899073e056e2a2fc325ed29dae
45ed29daeb9940c119073e056e2a2fc32
5e2a2fc32fa62d3a4b9940c119073e056
69073e056b88dc1c7fa62d3a4b9940c11
7b9940c11a089a530b88dc1c7fa62d3a4
8fa62d3a4c63616cda089a530b88dc1c7
9b88dc1c7fcced5dbc63616cda089a530
10a089a5309bb4c658fcced5dbc63616cd
11c63616cd4731c0779bb4c658fcced5db
12fcced5db5ff4a4e84731c0779bb4c658
139bb4c65827c95b7f5ff4a4e84731c077
144731c07734e999227c95b7f5ff4a4e8
155ff4a4e8872d34d834e999227c95b7f
1627c95b7fb760921a872d34d834e9992
1734e99926d3425b2b760921a872d34d8
18872d34d8551aefa36d3425b2b760921a
19b760921a62cdb24b551aefa36d3425b2
206d3425b2f615fbe562cdb24b551aefa3
21551aefa33d3c3afcf615fbe562cdb24b
2262cdb24b343bff123d3c3afcf615fbe5
23f615fbe599351d3c343bff123d3c3afc
243d3c3afce7f48f5999351d3c343bff12
25343bff127247931ae7f48f5999351d3c
2699351d3ce37cf5f67247931ae7f48f59
27e7f48f59709f1676e37cf5f67247931a
287247931a2460ff57709f1676e37cf5f6
29e37cf5f6c64f6e002460ff57709f1676
30709f16764e341514c64f6e002460ff57
312460ff5799ccfca34e341514c64f6e00
32c64f6e0029209d1f99ccfca34e341514
334e3415147b425bcb29209d1f99ccfca3
3499ccfca31d72c0d57b425bcb29209d1f
3529209d1f8139174f1d72c0d57b425bcb
367b425bcb77401eff8139174f1d72c0d5
371d72c0d52e678c5177401eff8139174f
388139174faf1a865c2e678c5177401eff
3977401eff26bbf48daf1a865c2e678c51
402e678c511eaad7f926bbf48daf1a865c
41af1a865cff95dbf71eaad7f926bbf48d
4226bbf48d9ff8129cff95dbf71eaad7f9
431eaad7f9580f8d8e9ff8129cff95dbf7
44ff95dbf749bd582a580f8d8e9ff8129c
459ff8129cc5148eb049bd582a580f8d8e
46580f8d8e9551398bc5148eb049bd582a
4749bd582a8ee8cb359551398bc5148eb0
48c5148eb08f920a7f8ee8cb359551398b
499551398b1158f5628f920a7f8ee8cb35
508ee8cb353a3bd4bf1158f5628f920a7f
518f920a7f3250a7903a3bd4bf1158f562
521158f562ed9ac5d43250a7903a3bd4bf
533a3bd4bf7e40a029ed9ac5d43250a790
543250a790778e9f997e40a029ed9ac5d4
55ed9ac5d4555e3d90778e9f997e40a029
567e40a029c004fc5d555e3d90778e9f99
57778e9f99853d163fc004fc5d555e3d90
58555e3d9057ff85d4853d163fc004fc5d
59c004fc5d61367f6557ff85d4853d163f
60853d163f671dc23661367f6557ff85d4
6157ff85d4162448f8671dc23661367f65
6261367f65c02f9d34162448f8671dc236
63671dc23698747d54c02f9d34162448f8
64162448f89dc60bf398747d54c02f9d34

Result

f96b697d7cb7938d525a2f31aaf161d0

Cross-segment length string

Input

ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789

Preprocessed

44434241 48474645 4c4b4a49 504f4e4d
54535251 58575655 62615a59 66656463
6a696867 6e6d6c6b 7271706f 76757473
7a797877 33323130 37363534 00803938

00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 000001f0 00000000

Steps

SegmentStepabcd
1067452301efcdab8998badcfe10325476
1110325476c6c10796efcdab8998badcfe
1298badcfe99a09999c6c10796efcdab89
13efcdab891106798099a09999c6c10796
14c6c1079627bce07a1106798099a09999
1599a09999f22e6c4e27bce07a11067980
1611067980b4ac9218f22e6c4e27bce07a
1727bce07aa95a2fc0b4ac9218f22e6c4e
18f22e6c4ea4799506a95a2fc0b4ac9218
19b4ac92181eb3e7c1a4799506a95a2fc0
110a95a2fc0a6e70cfe1eb3e7c1a4799506
111a4799506ca27520ba6e70cfe1eb3e7c1
1121eb3e7c18a7612ecca27520ba6e70cfe
113a6e70cfe3cbdcd458a7612ecca27520b
114ca27520bb8dec7633cbdcd458a7612ec
1158a7612ecfa148c8ab8dec7633cbdcd45
1163cbdcd455d38e690fa148c8ab8dec763
117b8dec7634b9d52a5d38e690fa148c8a
118fa148c8a783002eb4b9d52a5d38e690
1195d38e690d3ee3ed1783002eb4b9d52a
1204b9d52a47ae7c81d3ee3ed1783002eb
121783002eb2d7d8a3f47ae7c81d3ee3ed1
122d3ee3ed1d12108232d7d8a3f47ae7c81
12347ae7c814b534dc3d12108232d7d8a3f
1242d7d8a3f752920304b534dc3d1210823
125d12108239d2a6e33752920304b534dc3
1264b534dc3e8d2e449d2a6e3375292030
12775292030d473b564e8d2e449d2a6e33
1289d2a6e33f2ff6ea0d473b564e8d2e44
129e8d2e449b085fa9f2ff6ea0d473b564
130d473b5644400a9bd9b085fa9f2ff6ea0
131f2ff6ea05993248f4400a9bd9b085fa9
1329b085fa9dd789ecc5993248f4400a9bd
1334400a9bd21c8d2b7dd789ecc5993248f
1345993248f1d55a18e21c8d2b7dd789ecc
135dd789ecc56ec1191d55a18e21c8d2b7
13621c8d2b71b9504f856ec1191d55a18e
1371d55a18e436b7fe91b9504f856ec119
13856ec11975800c1436b7fe91b9504f8
1391b9504f8f404c2f675800c1436b7fe9
140436b7fe9cf0341edf404c2f675800c1
14175800c1888e7d8acf0341edf404c2f6
142f404c2f6bbdaecd8888e7d8acf0341ed
143cf0341edce620273bbdaecd8888e7d8a
144888e7d8a47b9419ce620273bbdaecd8
145bbdaecd82dbee21d47b9419ce620273
146ce620273e95c3a432dbee21d47b9419
14747b9419ee46e961e95c3a432dbee21d
1482dbee21df166f514ee46e961e95c3a43
149e95c3a43e47fd4f3f166f514ee46e961
150ee46e961fb887751e47fd4f3f166f514
151f166f514f22aedccfb887751e47fd4f3
152e47fd4f37a13bc5cf22aedccfb887751
153fb887751a691d4307a13bc5cf22aedcc
154f22aedcc528452f2a691d4307a13bc5c
1557a13bc5c3fc23df6528452f2a691d430
156a691d430efb0e72f3fc23df6528452f2
157528452f227145703efb0e72f3fc23df6
1583fc23df621a1106927145703efb0e72f
159efb0e72f374fbe7921a1106927145703
1602714570349d9a5b4374fbe7921a11069
16121a110691cb80f0a49d9a5b4374fbe79
162374fbe79ea3d3eb41cb80f0a49d9a5b4
16349d9a5b410f68731ea3d3eb41cb80f0a
1641cb80f0aef2e3a4610f68731ea3d3eb4
2083fd320bdefbe5cfa9b1642ffa6f932a
21fa6f932aeda23ed1defbe5cfa9b1642f
22a9b1642f989939cfeda23ed1defbe5cf
23defbe5cf3c307338989939cfeda23ed1
24eda23ed1ddcf06343c307338989939cf
25989939cf75144433ddcf06343c307338
263c307338c887580775144433ddcf0634
27ddcf0634c783cb60c887580775144433
287514443399b6b699c783cb60c8875807
29c8875807a60a3f6999b6b699c783cb60
210c783cb60aa6630bea60a3f6999b6b699
21199b6b69964db26e9aa6630bea60a3f69
212a60a3f6964cc7c5a64db26e9aa6630be
213aa6630bea70737da64cc7c5a64db26e9
21464db26e95473f8a7a70737da64cc7c5a
21564cc7c5a96f6586e5473f8a7a70737da
216a70737daa36f556f96f6586e5473f8a7
2175473f8a7a5050ad3a36f556f96f6586e
21896f6586e28776046a5050ad3a36f556f
219a36f556f27dcd8b428776046a5050ad3
220a5050ad382b8827c27dcd8b428776046
22128776046e04f070c82b8827c27dcd8b4
22227dcd8b42f3cd2a2e04f070c82b8827c
22382b8827cc0d22b612f3cd2a2e04f070c
224e04f070cdf35cb56c0d22b612f3cd2a2
2252f3cd2a2242dd210df35cb56c0d22b61
226c0d22b61576ace33242dd210df35cb56
227df35cb565c295967576ace33242dd210
228242dd2102291191a5c295967576ace33
229576ace3324eba6952291191a5c295967
2305c2959674bd0378b24eba6952291191a
2312291191a10c42a2f4bd0378b24eba695
23224eba6959c03e2e810c42a2f4bd0378b
2334bd0378b5be1d5269c03e2e810c42a2f
23410c42a2f9e4142795be1d5269c03e2e8
2359c03e2e89f4a1a7e9e4142795be1d526
2365be1d526a24484539f4a1a7e9e414279
2379e414279e14e403da24484539f4a1a7e
2389f4a1a7ee8cfd670e14e403da2448453
239a244845360cc183ae8cfd670e14e403d
240e14e403dfe31412160cc183ae8cfd670
241e8cfd670fff62809fe31412160cc183a
24260cc183ae37209acfff62809fe314121
243fe3141218cb5221ce37209acfff62809
244fff628097c7e974c8cb5221ce37209ac
245e37209ac54c9eb3a7c7e974c8cb5221c
2468cb5221cd4d9c6ac54c9eb3a7c7e974c
2477c7e974c2ec86f72d4d9c6ac54c9eb3a
24854c9eb3a79c0710a2ec86f72d4d9c6ac
249d4d9c6ac2095af179c0710a2ec86f72
2502ec86f7213d245fd2095af179c0710a
25179c0710aa8dcfe2613d245fd2095af1
2522095af12ba98e3fa8dcfe2613d245fd
25313d245fde126c1aa2ba98e3fa8dcfe26
254a8dcfe2696b00fa7e126c1aa2ba98e3f
2552ba98e3f6f287ff596b00fa7e126c1aa
256e126c1aafb7bcee06f287ff596b00fa7
25796b00fa7452c1099fb7bcee06f287ff5
2586f287ff5ca801ba6452c1099fb7bcee0
259fb7bcee0c197ea8eca801ba6452c1099
260452c10995ac74608c197ea8eca801ba6
261ca801ba614ae42c65ac74608c197ea8e
262c197ea8ea52dae7514ae42c65ac74608
2635ac74608826afd76a52dae7514ae42c6
26414ae42c616dd9203826afd76a52dae75

Result

d174ab98d277d9f5a5611c2c9f419d9f

Long string

Input

12345678901234567890123456789012345678901234567890123456789012345678901234567890

Preprocessed

34333231 38373635 32313039 36353433
30393837 34333231 38373635 32313039
36353433 30393837 34333231 38373635
32313039 36353433 30393837 34333231

38373635 32313039 36353433 30393837
00000080 00000000 00000000 00000000
00000000 00000000 00000000 00000000
00000000 00000000 00000280 00000000

Steps

SegmentStepabcd
1067452301efcdab8998badcfe10325476
1110325476beb8ff8eefcdab8998badcfe
1298badcfe7d989d89beb8ff8eefcdab89
13efcdab89f8cdf95d7d989d89beb8ff8e
14beb8ff8e862797b0f8cdf95d7d989d89
157d989d898c17de9f862797b0f8cdf95d
16f8cdf95dc0f32d818c17de9f862797b0
17862797b0e99fec1bc0f32d818c17de9f
188c17de9fc57e78c1e99fec1bc0f32d81
19c0f32d817c0aceb7c57e78c1e99fec1b
110e99fec1b8869d2d87c0aceb7c57e78c1
111c57e78c15186a8ba8869d2d87c0aceb7
1127c0aceb7a5f36f8d5186a8ba8869d2d8
1138869d2d85157e49ea5f36f8d5186a8ba
1145186a8baffac907e5157e49ea5f36f8d
115a5f36f8d27e983a0ffac907e5157e49e
1165157e49eaf506a0327e983a0ffac907e
117ffac907e8d18e0e8af506a0327e983a0
11827e983a07de0df28d18e0e8af506a03
119af506a03ef2231677de0df28d18e0e8
1208d18e0e84280170ef2231677de0df2
1217de0df278929ee04280170ef223167
122ef223167375c6c2c78929ee04280170
1234280170b18aca50375c6c2c78929ee0
12478929ee0ad400a91b18aca50375c6c2c
125375c6c2cbb45f43fad400a91b18aca50
126b18aca50d61f8a0fbb45f43fad400a91
127ad400a9198ade6b5d61f8a0fbb45f43f
128bb45f43fb70e35a998ade6b5d61f8a0f
129d61f8a0ff8bcfbb0b70e35a998ade6b5
13098ade6b5d760ed39f8bcfbb0b70e35a9
131b70e35a999a0f1b8d760ed39f8bcfbb0
132f8bcfbb01bf2566299a0f1b8d760ed39
133d760ed393dbd76ca1bf2566299a0f1b8
13499a0f1b8fd0561713dbd76ca1bf25662
1351bf25662c7ed7c30fd0561713dbd76ca
1363dbd76cae0162f49c7ed7c30fd056171
137fd0561713b32c408e0162f49c7ed7c30
138c7ed7c307338d8b73b32c408e0162f49
139e0162f499ef871ad7338d8b73b32c408
1403b32c4081d4d6f729ef871ad7338d8b7
1417338d8b7c661460a1d4d6f729ef871ad
1429ef871add2bf04c9c661460a1d4d6f72
1431d4d6f72d6d5b879d2bf04c9c661460a
144c661460a89e3c4d7d6d5b879d2bf04c9
145d2bf04c9697032ec89e3c4d7d6d5b879
146d6d5b879fa597bfc697032ec89e3c4d7
14789e3c4d7efc2c171fa597bfc697032ec
148697032ecdb4197daefc2c171fa597bfc
149fa597bfc57b91acadb4197daefc2c171
150efc2c171210c9ebc57b91acadb4197da
151db4197da21efbd88210c9ebc57b91aca
15257b91acacaa25b0121efbd88210c9ebc
153210c9ebc633d3f7ccaa25b0121efbd88
15421efbd881a4d3beb633d3f7ccaa25b01
155caa25b01ccaa15241a4d3beb633d3f7c
156633d3f7c7713f5dfccaa15241a4d3beb
1571a4d3beb8448b4307713f5dfccaa1524
158ccaa152471c934638448b4307713f5df
1597713f5df7e29472771c934638448b430
1608448b430660a801d7e29472771c93463
16171c93463614868eb660a801d7e294727
1627e294727a09f38a7614868eb660a801d
163660a801d5133129ba09f38a7614868eb
164614868ebb4d331025133129ba09f38a7
20c88d8beca4a0dc8be9edef99b0d18d1d
21b0d18d1d353af7cfa4a0dc8be9edef99
22e9edef993a4f735a353af7cfa4a0dc8b
23a4a0dc8b633565373a4f735a353af7cf
24353af7cf45e88f2c633565373a4f735a
253a4f735a3527497e45e88f2c63356537
2663356537ab92660e3527497e45e88f2c
2745e88f2c948347aeab92660e3527497e
283527497e377c7d0a948347aeab92660e
29ab92660ecc912f27377c7d0a948347ae
210948347ae6945a3d5cc912f27377c7d0a
211377c7d0aae23894d6945a3d5cc912f27
212cc912f27b9ede40cae23894d6945a3d5
2136945a3d5db4ff71cb9ede40cae23894d
214ae23894d9b6b4960db4ff71cb9ede40c
215b9ede40c4396a399b6b4960db4ff71c
216db4ff71c58b12eab4396a399b6b4960
2179b6b496052c00cae58b12eab4396a39
2184396a39aad2a21652c00cae58b12eab
21958b12eaba476af6faad2a21652c00cae
22052c00cae50f8de8ca476af6faad2a216
221aad2a216d6e6d9150f8de8ca476af6f
222a476af6f17d64195d6e6d9150f8de8c
22350f8de8cd5b7a85017d64195d6e6d91
224d6e6d9143cb080d5b7a85017d64195
22517d6419574f9377e43cb080d5b7a850
226d5b7a8501f2addd74f9377e43cb080
22743cb080e775c8ca1f2addd74f9377e
22874f9377ecb00b96ee775c8ca1f2addd
2291f2addd8761f38ecb00b96ee775c8ca
230e775c8ca7a5161168761f38ecb00b96e
231cb00b96e61bc8677a5161168761f38e
2328761f38e67092c3361bc8677a516116
2337a51611691044d5d67092c3361bc867
23461bc867610954eb91044d5d67092c33
23567092c33c0175fa8610954eb91044d5d
23691044d5d2ee1e3fec0175fa8610954eb
237610954ebae26ed7d2ee1e3fec0175fa8
238c0175fa871d8eceaae26ed7d2ee1e3fe
2392ee1e3feff4a94dc71d8eceaae26ed7d
240ae26ed7ddbd1bff6ff4a94dc71d8ecea
24171d8ecea9c350028dbd1bff6ff4a94dc
242ff4a94dc97e5da929c350028dbd1bff6
243dbd1bff6facaaf0697e5da929c350028
2449c35002856b3692ffacaaf0697e5da92
24597e5da9271123afa56b3692ffacaaf06
246facaaf06dc9c8ddb71123afa56b3692f
24756b3692fe6a8a386dc9c8ddb71123afa
24871123afa1df7010ae6a8a386dc9c8ddb
249dc9c8ddbd29007e71df7010ae6a8a386
250e6a8a3867241a77ed29007e71df7010a
2511df7010ad32481097241a77ed29007e7
252d29007e7c8797828d32481097241a77e
2537241a77e7a504abdc8797828d3248109
254d3248109211cc65d7a504abdc8797828
255c8797828a290d6ce211cc65d7a504abd
2567a504abd9b31b114a290d6ce211cc65d
257211cc65d723fd22d9b31b114a290d6ce
258a290d6ced21d6a3b723fd22d9b31b114
2599b31b1143d79cf74d21d6a3b723fd22d
260723fd22d4dc4f33d3d79cf74d21d6a3b
261d21d6a3bda67616b4dc4f33d3d79cf74
2623d79cf74c9e47a04da67616b4dc4f33d
2634dc4f33d44ec5a13c9e47a04da67616b
264da67616bb12906a044ec5a13c9e47a04

Result

57edf4a22be3c955ac49da2e2107b67a