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
#include <string.h>
15
16
#if defined(STDC_HEADERS)
17
#include <string.h>
18
#endif
19
20
#include "fm_md5.h"
21
22
char *
23
MD5Digest (unsigned const 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((const char *)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
}