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
A more concise and performant (see https://jsperf.com/byte-array-to-hex-string) alternative using Array.reduce():
function toHexString(byteArray) {
return byteArray.reduce((output, elem) =>
(output + ('0' + elem.toString(16)).slice(-2)),
'');
}
(Also without "& 0xFF" because in my opinion if an array is passed in that contains values larger than 255, the output should be messed up, so that the user can more easily see that their input was wrong.)