Back to index

courier  0.68.2
md5test.c
Go to the documentation of this file.
00001 /*
00002 ** Copyright 1998 - 2000 Double Precision, Inc.
00003 ** See COPYING for distribution information.
00004 */
00005 
00006 #include      "md5.h"
00007 #include      <stdio.h>
00008 #include      <string.h>
00009 
00010 int    main()
00011 {
00012 static const char * const teststr[]={
00013 "",
00014 "a",
00015 "abc",
00016 "message digest",
00017 "abcdefghijklmnopqrstuvwxyz",
00018 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
00019 "12345678901234567890123456789012345678901234567890123456789012345678901234567890"};
00020 
00021 char   *salts[4]={"abcdef","01234567","76543210","QWERTY"};
00022 char   *passwds[4]={ "rosebud",
00023                      "trust noone",
00024                      "trust, but verify",
00025                      "for the world is hollow, and I have touched the sky"};
00026 
00027 int    i,j;
00028 
00029        printf("MD5 test suite:\n");
00030        for (i=0; i<(int)sizeof(teststr)/sizeof(teststr[0]); i++)
00031        {
00032        MD5_DIGEST digest;
00033 
00034               md5_digest(teststr[i], strlen(teststr[i]), digest);
00035 
00036               printf("MD5 (\"%s\") = ", teststr[i]);
00037               for (j=0; j<sizeof(digest); j++)
00038                      printf("%02x", digest[j]);
00039               printf("\n");
00040        }
00041        for (i=0; i<sizeof(salts)/sizeof(salts[0]); i++)
00042               printf("Salt: %s\nPassword: %s\nHash:%s\n\n",
00043                             salts[i], passwds[i],
00044                             md5_crypt_redhat(passwds[i], salts[i]));
00045        return (0);
00046 }