1 #include "lib.h"
2 #include "md5.h"
3
4 const char *testpairs[] = {
5 "",
6 "d41d8cd98f00b204e9800998ecf8427e",
7 "T",
8 "b9ece18c950afbfa6b0fdbfa4ff731d3",
9 "Th",
10 "eeeb9a8eb45dd351d9ec0eb4acce66ce",
11 "The",
12 "a4704fd35f0308287f2937ba3eccf5fe",
13 "The ",
14 "02edd93949f6d3c57d9822691b59f649",
15 "The q",
16 "6131a51747610d0ae4e86c3a3416788c",
17 "The qu",
18 "8c871099d54c09d4099fa7a0e77c9113",
19 "The qui",
20 "bbb9873bad399cd1cc0d5e336ca5beee",
21 "The quic",
22 "b9b926544b8ecd5c3ef553a87170b726",
23 "The quick",
24 "912d57cea222bc1730dd531b9d6afbb6",
25 "The quick ",
26 "03c729679ca3252a4735c4148b7c11e3",
27 "The quick b",
28 "d7027ce01f22eb9d2bb32d9a153a7e29",
29 "The quick br",
30 "e05e6a516c92259691cf9194dfdeff92",
31 "The quick bro",
32 "dd1ac3c70b6f51dd545cdf64053209d4",
33 "The quick brow",
34 "caa1e1e79c65480a48cf08a38ac1d87d",
35 "The quick brown",
36 "5aa207e85988921b8733912c4f526c80",
37 "The quick brown ",
38 "b0e45b65d9e1d88169c40dc47605e2d9",
39 "The quick brown f",
40 "e4b6d6fabe9dfcbe83a51d19df5f0ac3",
41 "The quick brown fo",
42 "168534eca593b6cef86aea9081f0f5bf",
43 "The quick brown fox",
44 "a2004f37730b9445670a738fa0fc9ee5",
45 "The quick brown fox ",
46 "c4314972a672ded8759cafdca9af3238",
47 "The quick brown fox j",
48 "29dcbbf4add427ccba06d3c37ad44aa9",
49 "The quick brown fox ju",
50 "d0312d0e9e2d8c063d95a06fbbba9cb1",
51 "The quick brown fox jum",
52 "770fd972e360cb8538ce6a880741936e",
53 "The quick brown fox jump",
54 "8e53cb84ef3d981a86fbb69b24827c46",
55 "The quick brown fox jumps",
56 "83de97cab1f553eb3acc22866a4f6942",
57 "The quick brown fox jumps ",
58 "a2829f93d701f36d808d0a698dcebf02",
59 "The quick brown fox jumps o",
60 "efcead92aba26426db84b75413f17c10",
61 "The quick brown fox jumps ov",
62 "60a0732774106c2348eb576596668eb9",
63 "The quick brown fox jumps ove",
64 "d44f138aa2f39488c03391771eea258c",
65 "The quick brown fox jumps over",
66 "f85199fa76594dfb190fab5dfe42a769",
67 "The quick brown fox jumps over ",
68 "cd4c02f190df2372cb703994dd84e881",
69 "The quick brown fox jumps over t",
70 "566cb723d4fb7a7dd38163532fe760b7",
71 "The quick brown fox jumps over th",
72 "4433001bd59da157c18b09f6c10d4163",
73 "The quick brown fox jumps over the",
74 "b76b517e01f5b708af50af906adb2dac",
75 "The quick brown fox jumps over the ",
76 "0f611396bcfe9ab7666c45ebd37e59ba",
77 "The quick brown fox jumps over the l",
78 "4c6606c2117565959048d356c1d7f6cc",
79 "The quick brown fox jumps over the la",
80 "5f7f3f510b8a8f0a5e1d6193c6c7f3af",
81 "The quick brown fox jumps over the laz",
82 "542560ce828579cfe777aa165b4d1bed",
83 "The quick brown fox jumps over the lazy",
84 "171e092149d366acca00d1cd783e61cd",
85 "The quick brown fox jumps over the lazy ",
86 "4ed8b5a69f7c329f498320947db666f2",
87 "The quick brown fox jumps over the lazy d",
88 "eb4c251a5abb3c59d306276ba2dc644d",
89 "The quick brown fox jumps over the lazy do",
90 "2b6e07526e77047d7935681efc3b9f90",
91 "The quick brown fox jumps over the lazy dog",
92 "9e107d9d372bb6826bd81d3542a419d6",
93 "The quick brown fox jumps over the lazy dog.",
94 "e4d909c290d0fb1ca068ffaddf22cbd0",
95 "The quick brown fox jumps over the lazy dog. ",
96 "1c6d98786bea70b9c34ce7f33201120c",
97 "The quick brown fox jumps over the lazy dog. T",
98 "65ddd1c2fc3e4dfd4fe542b87165cedf",
99 "The quick brown fox jumps over the lazy dog. Th",
100 "4201abeb6911b3e2ffb31d06b09af97d",
101 "The quick brown fox jumps over the lazy dog. The",
102 "dc3569f2edadfd3cbbaf1bb12a648e4b",
103 "The quick brown fox jumps over the lazy dog. The ",
104 "6eecd04cabc9a4f8d933e40eeced5532",
105 "The quick brown fox jumps over the lazy dog. The q",
106 "766f9f17894f3a0eacef3f84667b55ce",
107 "The quick brown fox jumps over the lazy dog. The qu",
108 "0c30c95724fff5016e6a1918cb1ca2b3",
109 "The quick brown fox jumps over the lazy dog. The qui",
110 "4f29855b961a796e8d368d7564ac3a0b",
111 "The quick brown fox jumps over the lazy dog. The quic",
112 "ce3a1bd17d22ae5b47ed44f091c9f176",
113 "The quick brown fox jumps over the lazy dog. The quick",
114 "4e0a6194f8f414c28da89440156a9009",
115 "The quick brown fox jumps over the lazy dog. The quick ",
116 "02d3c665bf9cc21f31651cdc7f2ccdea",
117 "The quick brown fox jumps over the lazy dog. The quick b",
118 "b35c6984867c4dc932f9d42ba87cc3b5",
119 "The quick brown fox jumps over the lazy dog. The quick br",
120 "f98b6d7b5b4959d79a2b6b5b26cf9b7a",
121 "The quick brown fox jumps over the lazy dog. The quick bro",
122 "dac8b3430fe201150242954c6daf8ea7",
123 "The quick brown fox jumps over the lazy dog. The quick brow",
124 "b8f24ed180755335e8be326e067ca468",
125 "The quick brown fox jumps over the lazy dog. The quick brown",
126 "e02c7f42bd44e07724e0f71cee642134",
127 "The quick brown fox jumps over the lazy dog. The quick brown ",
128 "2a0bf92b82f25992c9c417a070a397aa",
129 "The quick brown fox jumps over the lazy dog. The quick brown f",
130 "8a0c51850f03b4ad80e0851cbbe0fdf4",
131 "The quick brown fox jumps over the lazy dog. The quick brown fo",
132 "b1b073bd98cf9a2c4046024b0e1b6fce",
133 "The quick brown fox jumps over the lazy dog. The quick brown fox",
134 "3ec457cb6db1e6bcd662c3f3f4fe630c",
135 "The quick brown fox jumps over the lazy dog. The quick brown fox ",
136 "b55db249d5c7542264eecb1540835baf",
137 "The quick brown fox jumps over the lazy dog. The quick brown fox j",
138 "d07f7e87e25107445bc0473419c0fc63",
139 "The quick brown fox jumps over the lazy dog. The quick brown fox ju",
140 "8b2bfe36e5edfdb822a9d1fce113da81",
141 "The quick brown fox jumps over the lazy dog. The quick brown fox jum",
142 "89ca1465f682566dd60cfabfa3f11bf6",
143 "The quick brown fox jumps over the lazy dog. The quick brown fox jump",
144 "f74492f066757975747d63208074b6f3",
145 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps",
146 "472743ca68656efc1b22941801d2b3ac",
147 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps ",
148 "b86ca5ba3f97561a99898ce9b32bef84",
149 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps o",
150 "6a5cdb4e4a0537bc47add6f353f40d03",
151 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps ov",
152 "7ddafb434b98bb44260f5370c970fd2f",
153 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps ove",
154 "e2979dc7906b441f3dfeda505d001c5d",
155 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over",
156 "3f946b37a2e2deec4e592af669c3dc61",
157 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over ",
158 "e6e019b6b8df0119334962125e06d842",
159 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over t",
160 "9871f053ed93e778d5090e3dc038815d",
161 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over th",
162 "fa1f4e6d041152dd28c32ec0ee565c13",
163 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the",
164 "195419e61a49df4c10a3f548ccc670b2",
165 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the ",
166 "7a430c4e49148f93769297a6dfa0446b",
167 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the l",
168 "6a9a844beaf2dba967b5519f5b030ff5",
169 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the la",
170 "b745c9f10771719f69f2f244279f8b3f",
171 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the laz",
172 "46872c15d6fa266689583f58e33c08ad",
173 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy",
174 "59caddaa702704eaec934cf9f0cbd51a",
175 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy ",
176 "3dd3ff2d571a54649c1a990ba68b9ef8",
177 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy d",
178 "2f9f8e8986602c8035dc6cbe9d1bf0b4",
179 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy do",
180 "eb88f590f024cc3e3ddc7dea5b633f32",
181 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog",
182 "059587551f430b5b4fe2804c1291c949",
183 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.",
184 "f168d89e05b664041ee6745f050caa4b",
185 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. ",
186 "3db4408fe73eb3a3d019013a833c5352",
187 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. T",
188 "fb019f3a29510a824744fb681975e0e3",
189 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. Th",
190 "3a73a0e3546de61980ffcd6599e2cce2",
191 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The",
192 "b1b9bebdc6c4d1bc9ced10a41f047757",
193 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The ",
194 "ea097330d1392892abffe9016d5036fb",
195 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The q",
196 "0a54a9f5677442446640f97455e845f1",
197 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The qu",
198 "8b156455848e5c5b482f3d8770b46a51",
199 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The qui",
200 "ff2500f43c2f3cf26a2327a5d4ec2d87",
201 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quic",
202 "8b5861337409e038ea5065918df850f3",
203 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick",
204 "2fc58fafbfb718e48bcdacdb8474ec0f",
205 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick ",
206 "8c8685b559f60724df36d4eeab36ba76",
207 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick b",
208 "b9e5b37a6c2fc492b8c38e884ef26715",
209 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick br",
210 "932fc0e7fde9e97ecdb1f82a77aaebab",
211 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick bro",
212 "b46271fdc7db2df406a8428add977a98",
213 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brow",
214 "b749afc6dd7f6b72ad6b9f8e2a11539b",
215 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown",
216 "f35e20073a3181fecf18bd814351873f",
217 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown ",
218 "00afd21a603dca4797a46abd95e1f176",
219 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown f",
220 "92a9cedaa5906c665413f0dd268e1b91",
221 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fo",
222 "6ef072127cbfdccf9120c479e6a18b3d",
223 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox",
224 "cd84e91cb86d6796a84769af50208048",
225 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox ",
226 "fd7029bde3c821d94c0af5ca2721994f",
227 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox j",
228 "3c22dc5501f2df92920fed7477d6d6ea",
229 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox ju",
230 "b3f71a58d072fcd2a14b3479f9694bb7",
231 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jum",
232 "32a821ae25769872d7f15fb686b24257",
233 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jump",
234 "c8ce85938d90db1587c3e93bffa6332d",
235 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps",
236 "f879a80b636be47979d104c3169e7d50",
237 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps ",
238 "2db3bd9a8ad6d7a7f7e42841a341d75e",
239 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps o",
240 "b3c49c0b6c311b0f0b08d1f55d35414d",
241 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps ov",
242 "ba1000775b5a42c5303c375f1a1713dc",
243 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps ove",
244 "a658d486ce1fe4acf615be3bdc9ca3da",
245 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over",
246 "a40e012c4c969f40fa07a92cef43cf28",
247 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over ",
248 "e18c5bc6c23223261bc10ffaa7ff00b3",
249 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over t",
250 "4a56d26e60b253d00cb41fe6233c19fe",
251 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over th",
252 "9b7152bc21e2c84cddfca21b4fba2fa6",
253 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the",
254 "ff97f7cfb8c6bf0b15e0e7052892d82d",
255 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the ",
256 "abbffe88f9a4b6150120f58662a2547e",
257 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the l",
258 "ab44c2cdcb452d203b54a27ff998b482",
259 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the la",
260 "345c7581b9719ca72e3fc4d1f663f529",
261 "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the laz",
262 "78e6ccc74d5b610483216ffed1742ba2",
263 NULL
264 };
265
Main()266 void Main() {
267 Int success = 0;
268 Int count = 0;
269 for (const char **p = testpairs; *p; p += 2) {
270 count++;
271 if (MD5::hexdigest(S(p[0]))->eq(p[1]))
272 success++;
273 }
274 Str *report =
275 S("MD5 (")->add(S(success))->add("/")->add(S(count))->add(" matches)");
276 Check(success == count, report->c_str());
277 }
278