this works for me on FreeBSD.
(you need to specify the md5 library to link)
export LDLIBS=-lmd
Code:
#include <string.h>
#include <stdio.h>
#include <sys/types.h>
#include <md5.h>
int main(int argc, char * argv) {
const char * p = "hello\n";
char buffer[512];
MD5Data((void *) p, strlen(p), buffer);
puts(buffer);
return 0;
}
Code:
$ ./md5
b1946ac92492d2347c6235b4d2611184
$ echo hello | md5
b1946ac92492d2347c6235b4d2611184
no error checking, no warranty