Javascript ArrayBuffer to Hex

后端 未结 9 562
迷失自我
迷失自我 2020-11-30 05:51

I\'ve got a Javascript ArrayBuffer that I would like to be converted into a hex string.

Anyone knows of a function that I can call or a pre written function already

9条回答
  •  鱼传尺愫
    2020-11-30 06:10

    The simplest way to convert arraybuffer to hex:

    const buffer = new Uint8Array([ 4, 8, 12, 16 ]);
    console.log(Buffer.from(buffer).toString("hex")); // = 04080c10
    

提交回复
热议问题