MD5 Implementation
July 20th, 2006
This is not really a post… let see it more like a “memo” since everytime I have to implement MD5 in some application I always forget how to do…
First of all, we need the md5.c and md5.h files (note that the source in the link is an “appended” version of md5.h + md5.c, but if you look for them singolarly on google you can find them already splitted).
Then we have to include the md5.h file in our source with an #include "md5.h".
Here there’s a code snippet of how to use it:
unsigned char *password = "hello, I'm a password!";
MD5_CTX ctx;
unsigned char password_hash[16];
MD5Init(&ctx);
MD5Update(&ctx, password, strlen((char *)password));
MD5Final(password_hash, &ctx);
We have to init the MD5 Context with MD5Init(), then update the MD5 with MD5Update() and saying to MD5 to store the result in password_hash by using MD5Final().
That’s all…
