I have this code that shows me the correct md5 line. I prefer to return a string to a function, but I have a problem converting the md5 values ββto my string. This is the code:
string calculatemd5(string msg)
{
string result;
const char* test = msg.c_str();
int i;
MD5_CTX md5;
MD5_Init (&md5);
MD5_Update (&md5, (const unsigned char *) test, msg.length());
unsigned char buffer_md5[16];
MD5_Final ( buffer_md5, &md5);
printf("Input: %s", test);
printf("\nMD5: ");
for (i=0;i<16;i++){
printf ("%02x", buffer_md5[i]);
result[i]=buffer_md5[i];
}
std::cout <<"\nResult:"<< result[i]<<endl;
return result;
}
For example, result[i]an ascii char is strange as follows: .
How can I solve this problem?
source
share