encode_hex
encode_hex 将缓冲区或字符串编码为带有 0x 前缀的十六进制字符串。
输入
| 名称 | 类型 | 描述 |
|---|---|---|
value | buffer、string、addon | 要编码的缓冲区或字符串。以 '0x' 开头的字符串将被解码为十六进制;否则,使用原始 UTF-8 字节。 |
输出
| 名称 | 类型 | 描述 |
|---|---|---|
value | string | 输入内容的十六进制表示形式,带有 0x 前缀 |
output "encoded_hex" {value = encode_hex("hello, world")}// > encoded_hex: 0x68656c6c6f2c20776f726c64
decode_hex
decode_hex 解码一个十六进制字符串,并将结果以缓冲区形式返回。
输入
| 名称 | 类型 | 描述 |
|---|---|---|
hex_string | string | 要解码的十六进制字符串(带或不带 0x 前缀) |
输出
| 名称 | 类型 | 描述 |
|---|---|---|
value | buffer | 解码后的十六进制字符串,以缓冲区形式返回 |
output "decoded_hex" {value = decode_hex("0x68656c6c6f2c20776f726c64")}// > decoded_hex: 0x68656c6c6f2c20776f726c64
Is this page helpful?