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
#