title: Byte array to Hex string conversion in javascript
body: <p>I have a byte array of the form <code>[4,-101,122,-41,-30,23,-28,3,..]</code> which I want to convert in the form <code>6d69f597b217fa333246c2c8</code>
  I'm using below function</p>
  
  <pre><code>function toHexString(bytes) {
    return bytes.map(function(byte) {
      return (byte &amp; 0xFF).toString(16)
    }).join('')
  }
  </code></pre>
  
  <p>which is giving me a string of the same form but I suspect that it's not an efficient conversion because the hex string is bit shorter than expected. I think translating should get "0a10a6dc".
  Please tell me if I'm wrong or is this a right conversion but maybe I'm not using the right byte array </p>
  
  <p>byte array <code>4,-127,45,126,58,-104,41,-27,-43,27,-35,100,-50,-77,93,-16,96,105,-101,-63,48,-105,49,-67,110,111,26,84,67,-89,-7,-50,10,-12,56,47,-49,-42,-11,-8,-96,-117,-78,97,-105,9,-62,-44,-97,-73,113,96,23,112,-14,-62,103,-104,90,-14,117,78,31,-116,-7</code></p>
  
  <p>Corresponding conversion <code>4812d7e3a9829e5d51bdd64ceb35df060699bc1309731bd6e6f1a5443a7f9ceaf4382fcfd6f5f8a08bb261979c2d49fb771601770f2c267985af2754e1f8cf9</code></p>