From the code below I am trying to get the result of the result var into a string var but no success so far.
What’s wrong? Why I can’t get the right result? If I print this directly it’s ok…
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <openssl/md5.h>
char *string = "stelios";
unsigned char s[MD5_DIGEST_LENGTH];
int main()
{
int i;
unsigned char result[MD5_DIGEST_LENGTH];
MD5(string, strlen(string), result);
// output
for(i = 0; i < MD5_DIGEST_LENGTH; i++){
sprintf(s,"%0x", result[i]);//
printf("%x",s[i]);
}
printf("\n%x",s);
return EXIT_SUCCESS;
}
Try this: