]>
Commit | Line | Data |
---|---|---|
18d5d330 | 1 | /* |
0545caaa AJ |
2 | * Copyright (C) 1996-2014 The Squid Software Foundation and contributors |
3 | * | |
4 | * Squid software is distributed under GPLv2+ license and includes | |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
18d5d330 | 7 | */ |
8 | ||
f7f3304a | 9 | #include "squid.h" |
18d5d330 | 10 | #include "md5.h" |
18d5d330 | 11 | |
12 | static void MDPrint(unsigned char digest[16]); | |
13 | static void MDString(char *string); | |
14 | ||
15 | static void | |
16 | MDString(char *string) | |
17 | { | |
18 | MD5_CTX context; | |
19 | unsigned char digest[16]; | |
20 | unsigned int len = strlen(string); | |
ee0f10fd | 21 | xMD5Init(&context); |
22 | xMD5Update(&context, string, len); | |
23 | xMD5Final(digest, &context); | |
18d5d330 | 24 | printf("MD5 (\"%s\") = ", string); |
25 | MDPrint(digest); | |
26 | printf("\n"); | |
27 | } | |
28 | ||
29 | static void | |
30 | MDPrint(unsigned char digest[16]) | |
31 | { | |
32 | unsigned int i; | |
33 | for (i = 0; i < 16; i++) | |
26ac0430 | 34 | printf("%02x", digest[i]); |
18d5d330 | 35 | } |
36 | ||
37 | int | |
38 | main(int argc, char **argv) | |
39 | { | |
40 | printf("MD5 test suite:\n"); | |
41 | MDString(""); | |
42 | MDString("a"); | |
43 | MDString("abc"); | |
44 | MDString("message digest"); | |
45 | MDString("abcdefghijklmnopqrstuvwxyz"); | |
6ca34f6f HN |
46 | MDString("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"); |
47 | MDString("1234567890123456789012345678901234567890" | |
48 | "1234567890123456789012345678901234567890"); | |
18d5d330 | 49 | return 0; |
50 | } | |
f53969cc | 51 |