hex.ts

Hex encoding and decoding helpers.

Declarations
#

2 declarations

view source

from_hex
#

hex.ts view source

(hex: string): Uint8Array<ArrayBufferLike> | null

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

Converts a Uint8Array to a lowercase hex string.

bytes

Binary data to encode.

type Uint8Array<ArrayBufferLike>

returns

string

Hex string with two characters per byte.

Imported by
#