hex

Table of Contents

Function

hex — encode/decode hexadecimal strings

Synopsis

hex(b: bytes) -> string
hex(s: string) -> bytes

Description

The hex function encodes a bytes value b as a hexadecimal string or decodes a hexadecimal string s into a bytes value.

Examples

Encode a simple bytes sequence as a hexadecimal string:

yield hex(this)
0x0102ff
Loading...

Decode a simple hex string:

yield hex(this)
"0102ff"
Loading...

Encode the bytes of an ASCII string as a hexadecimal string:

yield hex(bytes(this))
"hello,
world"
Loading...

Decode hex string representing ASCII into its string form:

yield string(hex(this))
"68656c6c6f20776f726c64"
Loading...
Next: is

SuperDB