Hex
@std/hex is a hybrid package: its public functions are written in Nubo and its conversion operations are implemented in Go.
import hex from "@std/hex"
let encoded = hex.encode("hello")println(encoded)println(hex.decode(encoded))This prints 68656c6c6f and then hello.
| Function | Returns | Meaning |
|---|---|---|
encode(value: string) | string | Encode the string’s bytes as lowercase hexadecimal. |
decode(value: string) | string | Decode hexadecimal bytes into a string. |
Invalid hexadecimal input raises a catchable error:
import hex from "@std/hex"
catch err { println(hex.decode("not-hex"))}
if !isNil(err) { println(err.message)}See Hybrid packages to build a similar module in your Go app.