Standard library
Hex
Hex encode and decode.
Introduction
Hex encode and decode. Import std/encoding/hex to bind the module as hex. Call free functions as hex.name(...). Struct methods use a receiver value.
/ std/encoding/hex
This page is the package reference for std/encoding/hex. Private helpers used only by co-located tests are not listed.
Functions
Free functions on hex. Each function has a short description, an example, then parameters and return shape.
encode
Encodes bytes or text as a hex string. Call form: hex.encode(b).
/ std/encoding/hex
$ s = hex.encode(b"hi")
Parameters: b: bytes or text to encode. Returns: Hex string.
decode
Decodes a hex string to bytes. Call form: hex.decode(s).
/ std/encoding/hex
$ b = hex.decode("6869")Parameters: s: hex text. Returns: Decoded bytes.