Convert AES encrypted string to hex in C++
<p>I have a char* string that I have encoded using AES encryption.  This string contains a wide range of hex characters, not just those viewable by ASCII.  I need to convert this string so I can send it through HTTP, which does not accept all of the characters generated by the encryption algorithm.</p>

<p>What is the best way to convert this string?  I have used the following function but there are a lot of blanks (0xFF), it cant convert all of the characters.</p>

<pre><code>char *strToHex(char *str){
   char *buffer = new char[(dStrlen(str)*2)+1];
   char *pbuffer = buffer;
   int len = strlen( str );
   for(int i = 0; i &lt; len ; ++i ){
      sprintf(pbuffer, "%02X", str[i]);
      pbuffer += 2;
   }
   return buffer;
}
</code></pre>

<p>Thank you,
Justin</p>
