Compute the md5 hash of a string with C++

-1

So basically I've seen people using C++ to calculate the md5 hash, but either it needs to install additional libraries or the input is something like unsigned int. Somehow #include <openssl/md5.h> doesn't work for me.

I've seen this but I have no idea of how to change a string into that format.

//empty string appended with 1 bit and zeroes till it is 512 bytes long as 16 32-bit words
unsigned int message[16] = {0x00000080, 0x00000000, 0x00000000, 0x00000000,
                            0x00000000, 0x00000000, 0x00000000, 0x00000000,
                            0x00000000, 0x00000000, 0x00000000, 0x00000000,
                            0x00000000, 0x00000000, 0x00000000, 0x00000000};

Is there like a single file and a fast way to compute the md5 hash of a string with just one Cpp file on Windows? Preferably there would be something like string message = "..." or even like cin>>message

I couldn't understand these but maybe you'll find them useful.
Implementation of MD5 in C
speeding up md5 program
Calculate MD5 of a string in C++

Thanks in advance!

EDIT: I'm NOT trying to get the md5 hash of a file. I'm trying to get the hash for an input string. The problem is, I can't really understand the code in other places so therefore I'm sincerely asking for an easily implemented code with cin and cout (or printf)

c++
string
hash
md5
asked on Stack Overflow Oct 1, 2020 by Benjamin2002 • edited Oct 1, 2020 by Benjamin2002

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0