Byte array to hexadecimal and back again in JavaScript I can generate a byte array with

var myByteArray = window.crypto.getRandomValues(new Uint8Array(16))


and I get 

181,143,16,173,231,56,63,149,181,185,224,124,84,230,123,36


I can then turn this into a string with 

cryptoHelpers.convertByteArrayToString(myByteArray);


and i get 

µ­ç8?µ¹à|Tæ{$


But what I really want is a 128 bit hexadecimal like...

6a3e52297b2e593f4d506f7164


And I want to be able to go back from hexadecimal to a byte array. 

Is there a copy and paste function or library to make this magic happen?
Here's something you can copy-paste in.

byteArray = new Uint8Array([181,143,16,173,231,56,63,149,181,185,224,124,84,230,123,36]);
function toHexString(byteArray) {
  return Array.prototype.map.call(byteArray, function(byte) {
    return ('0' + (byte &amp; 0xFF).toString(16)).slice(-2);
  }).join('');
}
function toByteArray(hexString) {
  var result = [];
  for (var i = 0; i &lt; hexString.length; i += 2) {
    result.push(parseInt(hexString.substr(i, 2), 16));
  }
  return result;
}
hexString = toHexString(byteArray);
byteArray = toByteArray(hexString);


From here/here.