hex.decode

Decodes a hex string into bytes.

Syntax

decode(string)

Parameters

Return value

A Uint8Array with decoded bytes.

Throws an error if the string is not a valid hex string.

Example

hex.decode("FF121B")
Uint8Array [255, 18, 27]
hex.decode("fF121b")
Uint8Array [255, 18, 27]
hex.decode("fF121")
Error: hex: invalid length for decoding