Convert a UTF-8 String to an ArrayBuffer With Hex

Hello, I don’t seem to understand how to convert the following string to the following hex string then to an ArrayBuffer.

String:
..d.....Vgq7DGmSzhj7XbdC828a63
Hex:
001d641605010015563061364864334d745146584465477a3937636431
ArrayBuffer:
image

If anyone could shed some light on the topic, I would greatly appreciate it.
Note: I tried this and this is the product I got v
image

Hello, @edwrddd! This should be pretty straightforward as you just create a Buffer object with your UTF-8 string and use Uint8Array to convert it to an ArrayBuffer.

Here’s some code to help you:

var words = "put your string here";

var theArrayBuffer = new Uint8Array(Buffer.from(words, "utf-8")).buffer;

Thanks, but I’d like to use this on client-sided JavaScript. Buffer isn’t supported frontend.

See this package for using Buffer on the browser: https://github.com/feross/buffer

Thanks, but that still isn’t seeming to do the trick. The first eight characters are returning as 2e2e 642e 2e2e 2e2e and they need to be 001e 6416 0501 0016. The funny thing is when I use an online converter, the first hex string returns the correct UTF-8 string, but the second one returns unicode periods instead of regular periods.