IacStdFunctions

Hex Functions

Standard library functions for hexadecimal encoding and decoding

encode_hex

encode_hex encodes a buffer or string as a hexadecimal string with 0x prefix.

Inputs

NameTypeDescription
valuebuffer, string, addonThe buffer or string to encode. Strings starting with '0x' are decoded as hex; otherwise, raw UTF-8 bytes are used.

Output

NameTypeDescription
valuestringThe input in its hexadecimal representation with 0x prefix
output "encoded_hex" {
    value = encode_hex("hello, world")
}
// > encoded_hex: 0x68656c6c6f2c20776f726c64

decode_hex

decode_hex decodes a hexadecimal string and returns the result as a buffer.

Inputs

NameTypeDescription
hex_stringstringThe hex string to decode (with or without 0x prefix)

Output

NameTypeDescription
valuebufferThe decoded hex string as a buffer
output "decoded_hex" {
    value = decode_hex("0x68656c6c6f2c20776f726c64")
}
// > decoded_hex: 0x68656c6c6f2c20776f726c64

On this page