> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xray.cool/llms.txt
> Use this file to discover all available pages before exploring further.

# hex

> `hex`函数主要是用来将所给字符串或者字节数组进行十六进制编码，并输出编码后的字符串

## 函数原型

* `func hex(s1 string) string`
* `func hex(b1 bytes) string`

### 参数介绍

| 参数名称    | 参数介绍              |
| ------- | ----------------- |
| `s1/b1` | 为需要进行编码的字符串或者字节数组 |

## 举例

| 待转换数据     | 转换语句           | 输出结果       |
| --------- | -------------- | ---------- |
| `"asdf"`  | `hex("asdf")`  | `61736466` |
| `b"asdf"` | `hex(b"asdf")` | `61736466` |
