API reference@evolu/commonBuffer › hexToBytes

function hexToBytes(
  hex: string,
): Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>;

Defined in: node_modules/@noble/ciphers/utils.d.ts:305

Convert hex string to byte array. Uses built-in function, when available.

Throws

On wrong argument types. TypeError

Throws

On wrong argument ranges or values. RangeError

Example

Decode lowercase hexadecimal into bytes.

hexToBytes("cafe0123"); // Uint8Array.from([0xca, 0xfe, 0x01, 0x23])