/* md5hl.c
 * ----------------------------------------------------------------------------
 * "THE BEER-WARE LICENSE" (Revision 42):
 * <phk@login.dkuug.dk> wrote this file.  As long as you retain this notice you
 * can do whatever you want with this stuff. If we meet some day, and you think
 * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
 * ----------------------------------------------------------------------------
 *
 * $Id: ppvmd5hl.c,v 1.1.1.1 1998/11/09 23:23:04 lesterj Exp $
 *
 */

#include "ppvmd5.h"

char *
MD5End(MD5_CTX *ctx, char *p)
{
    int i;
    unsigned char digest[16];
    static const char hex[]="0123456789abcdef";

    MD5Final(digest,ctx);
    for(i=0;i<16;i++) {
	p[i+i] = hex[digest[i] >> 4];
	p[i+i+1] = hex[digest[i] & 0x0f];
    }
    p[i+i] = '\0';
    return p;
}

char *
MD5Data (char *buf, const unsigned char *data, unsigned int len)
{
    MD5_CTX ctx;

    MD5Init(&ctx);
    MD5Update(&ctx,data,len);
    return MD5End(&ctx, buf);
}
