← index

Hexabstract

inherits Object

Hexadecimal encoding between Bytes and text: two hex digits per byte, lower-case on encode, either case accepted on decode.

Bytes#toHex / String#fromHex wrap these as instance-side conveniences.

Hex.encode:'hi'.asBytes            "* -> '6869'
(Hex.decode:'6869').asString       "* -> 'hi'

Class methods

decode:String

The Bytes a hex String encodes — case-insensitive, surrounding whitespace ignored. Anything else throws a ValueError.

Hex.decode:'6869'     "* -> Bytes[2] 68 69

native

encode:Bytes

The lower-case hex String for some Bytes (two digits per byte).

Hex.encode:'hi'.asBytes     "* -> '6869'

native