Well, here's something I prepared earlier. The source of my program is here:
The key function is librad_md5_calc(unsigned char *output, unsigned char *input, unsigned int inputlen).
void hex_dump(unsigned char *, int);
char thing_to_md5 = "Hello, world!";
unsigned char result;
librad_md5_calc(result, thing_to_md5, strlen(thing_to_md5));
printf("md5 of %s is ", thing_to_md5);
void hex_dump(unsigned char *s, int sz)
for (i = 0; i < sz; i++)
output is a pointer to the buffer you want the result to go into, which will be 16 bytes. input is a pointer to the input buffer, and inputlen is the amount of bytes to read of the input buffer. This is because md5 works on arbitrary binary data, not just null terminated strings.
To convert the result from a 16 byte unsigned char array to the canonical ascii representation of an md5sum, I have used a simple hex_dump function to illustrate.
Of course, I have called one md5 implementation, which is too long to post here. I have attached md5.c and md5.h, the above program was appended to the bottom of md5.c, but for your own use, you should of course keep your normal code separate from md5.c
To confirm it's correct using the system md5sum utility:
md5 of Hello, world! is 6cd3556deb0da54bca060b4c39479839
echo -n 'Hello, world!' | md5sum