For those redirected from " https://stackoverflow.com/questions/4393017/md5-implementation-in-c , because it was incorrectly marked as duplicate.
The example given here works:
http://www.zedwood.com/article/cpp-md5-function
If you are compiling in VC ++ 2010, you will need to change its main.cpp to the following:
#include <iostream> //for std::cout
You will have to change the MD5 class a bit if you read in the char * array instead of a string to answer the question on this page here.
EDIT:
Apparently the change to the MD5 library is unclear, so the Full VC ++ 2010 solution includes char * for your convenience:
https://github.com/alm4096/MD5-Hash-Example-VS
A little explanation here:
#include <iostream> //for std::cout
I just added the following to the MD5 library:
MD5.cpp:
MD5::MD5(char * Input, long length) { init(); update(Input, length); finalize(); }
MD5.h:
std::string md5(char * Input, long length);
ALM865 Mar 05 '14 at 10:21 2014-03-05 22:21
source share