]> Pileus Git - ~andy/fetchmail/blob - md5ify.c
Initial revision
[~andy/fetchmail] / md5ify.c
1 /* Copyright 1993-95 by Carl Harris, Jr.
2  * All rights reserved
3  *
4  * Distribute freely, except: don't remove my name from the source or
5  * documentation (don't take credit for my work), mark your changes (don't
6  * get me blamed for your possible bugs), don't alter or remove this
7  * notice.  May be sold if buildable source is provided to buyer.  No
8  * warrantee of any kind, express or implied, is included with this
9  * software; use at your own risk, responsibility for damages (if any) to
10  * anyone resulting from the use of this software rests entirely with the
11  * user.
12  *
13  * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
14  * I'll try to keep a version up to date.  I can be reached as follows:
15  * Carl Harris <ceharris@mal.com>
16  */
17
18
19 /***********************************************************************
20   module:       md5ify.c
21   project:      popclient
22   programmer:   Carl Harris, ceharris@mal.com
23   description:  Simple interface to MD5 module.
24
25   $Log: md5ify.c,v $
26   Revision 1.1  1996/06/28 14:36:57  esr
27   Initial revision
28
29   Revision 1.1  1995/08/10 00:32:33  ceharris
30   Preparation for 3.0b3 beta release:
31   -     added code for --kill/--keep, --limit, --protocol, --flush
32         options; --pop2 and --pop3 options now obsoleted by --protocol.
33   -     added support for APOP authentication, including --with-APOP
34         argument for configure.
35   -     provisional and broken support for RPOP
36   -     added buffering to SockGets and SockRead functions.
37   -     fixed problem of command-line options not being correctly
38         carried into the merged options record.
39
40  ***********************************************************************/
41
42 #include <stdio.h>
43
44 #if defined(STDC_HEADERS)
45 #include <string.h>
46 #endif
47
48 #include "md5.h"
49
50 char *
51 MD5Digest (s)
52 char *s;
53 {
54   int i;
55   MD5_CTX context;
56   unsigned char digest[16];
57   static char ascii_digest [33];
58
59   MD5Init(&context);
60   MD5Update(&context, s, strlen(s));
61   MD5Final(digest, &context);
62   
63   for (i = 0;  i < 16;  i++) 
64     sprintf(ascii_digest+2*i, "%02x", digest[i]);
65  
66   return(ascii_digest);
67 }