Imported Upstream version 0.66.1
[hcoop/debian/courier-authlib.git] / libs / md5 / md5test.c
1 /*
2 ** Copyright 1998 - 2000 Double Precision, Inc.
3 ** See COPYING for distribution information.
4 */
5
6 #include "md5.h"
7 #include <stdio.h>
8 #include <string.h>
9
10 int main()
11 {
12 static const char * const teststr[]={
13 "",
14 "a",
15 "abc",
16 "message digest",
17 "abcdefghijklmnopqrstuvwxyz",
18 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
19 "12345678901234567890123456789012345678901234567890123456789012345678901234567890"};
20
21 char *salts[4]={"abcdef","01234567","76543210","QWERTY"};
22 char *passwds[4]={ "rosebud",
23 "trust noone",
24 "trust, but verify",
25 "for the world is hollow, and I have touched the sky"};
26
27 int i,j;
28
29 printf("MD5 test suite:\n");
30 for (i=0; i<(int)sizeof(teststr)/sizeof(teststr[0]); i++)
31 {
32 MD5_DIGEST digest;
33
34 md5_digest(teststr[i], strlen(teststr[i]), digest);
35
36 printf("MD5 (\"%s\") = ", teststr[i]);
37 for (j=0; j<sizeof(digest); j++)
38 printf("%02x", digest[j]);
39 printf("\n");
40 }
41 for (i=0; i<sizeof(salts)/sizeof(salts[0]); i++)
42 printf("Salt: %s\nPassword: %s\nHash:%s\n\n",
43 salts[i], passwds[i],
44 md5_crypt_redhat(passwds[i], salts[i]));
45 return (0);
46 }