title: Converting unsigned char array to hex
body: <p>I want to convert unsigned char to hex (using unsigned int). This is my code so far. I have a program1 that produces an unsigned char array and the other program2 only takes in only hex (using unsigned int), so what i want to achieve is getting an input of unsigned char array and converting that array into hex.
  <br>
  <br>
  (E.g., program1 outputs "1234567812345678", program2 should output "31323334353637383132333435363738") 
  <br>
  <br>
  Sorry if this question seems dumb. Looked around for answers here but it didn't seem to be what I wanted.</p>
  
  <pre><code>uint64_t phex (unsigned char[16], long);
  
  
  
  int main (void) {
  
  int i;
  unsigned char key[16] = "1234567812345678";
  
  
  uint64_t* keyHex = phex(key,16); //store into an array here
  
  for(i = 0; i &lt; 16; i++)
  printf("%.2x ", keyHex[i]);
  
  free(keyHex);
  
  return 0;
  
  }
  
  
  uint64_t phex(unsigned char* string, long len)
  {
  
  int i;
  //allocate memory for your array
  uint64_t* hex = (uint64_t*)malloc(sizeof(uint64_t) * len);
  
  for(i = 0; i &lt; len; ++i) {
      //do char to int conversion on every element of char array
      hex[i] = string[i] - '0';
  }
  
  //return integer array
  return hex;
  
  }
  </code></pre>