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

# sm3

> 使用 SM3 摘要算法将字符串加密为 256-bit 的十六进制字符串。

使用 SM3 摘要算法，将字符串 `str` 加密为 256-bit 的 十六进制字符串，每 32 位用空格分隔。

摘要算法广泛应用在数字签名，消息认证，数据完整性检测等领域。SM3 算法是在 SHA-256 基础上的改进。

## 语法

```Haskell theme={null}
SM3(str);
```

## 参数说明

`str`: 待加密的字符串，支持的数据类型为 VARCHAR。

## 返回值说明

返回值的数据类型为 VARCHAR。如果输入为 NULL，则返回 NULL。如果输入为空，则返回报错。

该函数仅接收一个字符串，如果输入多个字符串，会返回报错。

## 示例

```Plain Text theme={null}
mysql> select sm3('l');
+-------------------------------------------------------------------------+
| sm3('l')                                                                |
+-------------------------------------------------------------------------+
| 1dec1a7a 94236240 49db411e 2c32c62d c0c93856 8208ac3a 09d395eb 2468b445 |
+-------------------------------------------------------------------------+
1 row in set (0.01 sec)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.