A typed array has a toString
method that takes no argument, so providing 'hex'
to it will have no influence, it will just join the values into a comma-separated list of the values in decimal representation.
To get hexadecimal output, you'll need to iterate the array and convert each value to hex and concatenate the result:
const fromHexString = hexString => new Uint8Array(hexString.match(/.{1,2}/g).map(byte => parseInt(byte, 16)));
const toHexString = arr => Array.from(arr, i => i.toString(16).padStart(2, "0")).join("");
const arr = fromHexString('a0e30c9e46d8f973f4082d79fce1fb46b1c199bb047bb3545c85b545f7a1650a');
console.log(toHexString(arr));
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…