further merging: 0.4.67cvs6
[claws.git] / src / 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 #ifdef HAVE_CONFIG_H
14   #include "config.h"
15 #endif
16
17 #include <stdio.h>
18 #include <string.h>
19
20 #if defined(STDC_HEADERS)
21 #include <string.h>
22 #endif
23
24 #include "md5.h"
25
26 char *
27 MD5Digest (unsigned char *s)
28 {
29   int i;
30   MD5_CTX context;
31   unsigned char digest[16];
32   static char ascii_digest [33];
33
34   MD5Init(&context);
35   MD5Update(&context, s, strlen(s));
36   MD5Final(digest, &context);
37   
38   for (i = 0;  i < 16;  i++) 
39     sprintf(ascii_digest+2*i, "%02x", digest[i]);
40  
41   return(ascii_digest);
42 }