/*
 * compile with cc -o md5 md5.c -lbasis
 */
#include <stdio.h>
#include <md5lib.h>

main()
{
    JH handle;
    char bfr[512];
    unsigned char *sig;
    int siz, ix;

    if ((handle = md5_init()) == 0) {
        perror("md5_init");
        exit(1);
    }

    while ((siz = read(fileno(0), bfr, sizeof bfr)) > 0)
        md5_put(bfr, siz, handle);

    sig = md5_finish(handle, 0);

    for (ix = 0; ix < 16; ix++)
        printf("%02x", sig[ix]);
    putchar('\n');
}
