hex.ts

Hex encoding and decoding helpers.

view source

Declarations
#

2 declarations

from_hex
#

hex.ts view source

(hex: string): Uint8Array<ArrayBufferLike> | null import {from_hex} from '@fuzdev/fuz_util/hex.js';

Decodes a hex string to a Uint8Array. Whitespace is stripped before parsing. Returns null for invalid hex.

hex

hex string to decode (case-insensitive, whitespace allowed)

type string

returns

Uint8Array<ArrayBufferLike> | null

decoded bytes, or null if the input is not valid hex

to_hex
#

hex.ts view source

(bytes: Uint8Array<ArrayBufferLike>): string import {to_hex} from '@fuzdev/fuz_util/hex.js';

Converts a Uint8Array to a lowercase hex string.

bytes

type Uint8Array<ArrayBufferLike>

returns

string

hex string with two characters per byte

Imported by
#