safe-buffer icon indicating copy to clipboard operation
safe-buffer copied to clipboard

For Uint8Array in Type script

Open Lizard-King101 opened this issue 3 years ago • 0 comments

This took me way to long to figure out. In order to pass a Uint8Array to functions that need the normal node Buffer Uint8Array Type you must convert to unknown type and then Uint8Array type.

let hexstring = "572f3c5e8167f8b2cacba8036b9b37c3cc48b6a349ebbac561eec0089d222451";
let uint8arraytype = <Uint8Array><unknown>Buffer.from(hexstring, 'hex');

Lizard-King101 avatar May 05 '21 20:05 Lizard-King101