I have a byte array of the form [4,-101,122,-41,-30,23,-28,3,..]
which I want to convert in the form 6d69f597b217fa333246c2c8
I\'m using below func
Using map()
won't work if the input is of a type like Uint8Array
: the result of map()
is also Uint8Array
which can't hold the results of string conversion.
function toHexString(byteArray) {
var s = '0x';
byteArray.forEach(function(byte) {
s += ('0' + (byte & 0xFF).toString(16)).slice(-2);
});
return s;
}