Hex Encoding

Wikipedia: Hexadecimal
The hex module encodes bytes to a lowercase hexadecimal string and decodes hex strings back to bytes.

fmt := import("fmt")
hex := import("hex")
encoded := hex.encode(bytes("Hello"))
fmt.println(encoded)
decoded := hex.decode(encoded)
fmt.println(string(decoded))
fmt.println(hex.encode(bytes("AB")))
fmt.println(hex.encode(bytes("\x00\x01\x7f\xff")))

try it

48656c6c6f
Hello
4142
00017fff
loading…