title: Convert byte* to HEX String
body: <p>I'm trying to convert a <code>uint8_t</code> buffer into a HEX String:</p>
  
  <pre><code>uint16_t len = b.length();
  char* result = (char*) malloc(len * 2 * sizeof(char));
  int resPos=0;
  while (len &gt; 0) {
      uint8_t *buffer;
      uint8_t bytesToRead = min(32, len); 
      buffer = b.readBuffer(bytesToRead);
  
      for (int i = 0; i &lt; bytesToRead; i++) {
          char buf[3];
          sprintf(buf, "%02X", buffer[i]);
          OutPut.println(buf);
          //memcpy(result + resPos , buf,2);
          //resPos+=2;
          //OutPut.println(resPos);
      }
  
      len -= bytesToRead;
  }
  </code></pre>
  
  <p>Without the commented lines, I can see in my output, the hex values one at a time.</p>
  
  <p>What I would like to do, on the commented code, is return the whole HEX value as a <code>char*</code>. I tried the commented code and I have some memory errors.</p>