title: How to return the md5 hash in a string in this code C++?
body: <p>I have this code that show me correctly, the md5 of a string.
  I prefer to return a string to the function, but I have some problem converting the values of md5 into my string.
  This is the code:</p>
  
  <pre><code>string calculatemd5(string msg)
  {
  string result;
  const char* test = msg.c_str();
  int i;
  
  MD5_CTX md5;
  
  MD5_Init (&amp;md5);
  MD5_Update (&amp;md5, (const unsigned char *) test, msg.length());
  unsigned char buffer_md5[16];
  MD5_Final ( buffer_md5, &amp;md5);
  printf("Input: %s", test);
  printf("\nMD5: ");
  for (i=0;i&lt;16;i++){
      printf ("%02x", buffer_md5[i]);
      result[i]=buffer_md5[i];
  }
  std::cout &lt;&lt;"\nResult:"&lt;&lt; result[i]&lt;&lt;endl;
  return result;
  }
  </code></pre>
  
  <p>For example <code>result[i]</code> is a strange ascii char like this: <code>.</code>
  How can is possible solve this problem?</p>