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