]> Pileus Git - ~andy/fetchmail/blob - md5ify.c
0ca3e6b933fd9b9a9d43c4749072b36aec82ec53
[~andy/fetchmail] / md5ify.c
1 /*
2  * For license terms, see the file COPYING in this directory.
3  */
4
5 /***********************************************************************
6   module:       md5ify.c
7   project:      fetchmail
8   programmer:   Carl Harris, ceharris@mal.com
9   description:  Simple interface to MD5 module.
10
11  ***********************************************************************/
12
13 #include <stdio.h>
14
15 #if defined(STDC_HEADERS)
16 #include <string.h>
17 #endif
18
19 #include "md5.h"
20
21 char *
22 MD5Digest (s)
23 unsigned char *s;
24 {
25   int i;
26   MD5_CTX context;
27   unsigned char digest[16];
28   static char ascii_digest [33];
29
30   MD5Init(&context);
31   MD5Update(&context, s, strlen(s));
32   MD5Final(digest, &context);
33   
34   for (i = 0;  i < 16;  i++) 
35     sprintf(ascii_digest+2*i, "%02x", digest[i]);
36  
37   return(ascii_digest);
38 }