]> Pileus Git - ~andy/fetchmail/blob - md5ify.c
socket.c: drop OPENSSL_NO_SSL_INTERN, no longer needed.
[~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 "fetchmail.h"
14 #include "fm_md5.h"
15
16 #include <stdio.h>
17 #include <string.h>
18
19 char *
20 MD5Digest (unsigned const char *s)
21 {
22   int i;
23   MD5_CTX context;
24   unsigned char digest[16];
25   static char ascii_digest [33];
26
27   MD5Init(&context);
28   MD5Update(&context, s, strlen((const char *)s));
29   MD5Final(digest, &context);
30
31   for (i = 0;  i < 16;  i++) 
32     sprintf(ascii_digest+2*i, "%02x", digest[i]);
33  
34   return(ascii_digest);
35 }