Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add doc of sha2() #952

Merged
merged 1 commit into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions docs/MatrixOne/Reference/Functions-and-Operators/String/sha2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# **SHA2()**

## **函数说明**

`SHA2()` 加密函数用于计算输入字符串的 SHA2 哈希值。第一个参数是要散列的明文字符串。第二个参数指示结果的所需位长,其值必须为 224、256、384、512 或 0(相当于 256),分别对应了 SHA-224, SHA-256, SHA-384 和 SHA-512 算法。如果参数是 NULL 或者不是一个合法值将返回 NULL。

## **函数语法**

```
> SHA2(str, hash_length)
```

## **参数释义**

| 参数 | 说明 |
| -------- | ------------------------------------ |
| str | 必要参数。要计算哈希值的字符串 |
| hash_length | 必要参数。哈希长度。 |

## **示例**

```SQL
mysql> select sha2("hello world", 384);
+--------------------------------------------------------------------------------------------------+
| sha2(hello world, 384) |
+--------------------------------------------------------------------------------------------------+
| fdbd8e75a67f29f701a4e040385e2e23986303ea10239211af907fcbb83578b3e417cb71ce646efd0819dd8c088de1bd |
+--------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select sha2(null, 512);
+-----------------+
| sha2(null, 512) |
+-----------------+
| NULL |
+-----------------+
1 row in set (0.00 sec)

mysql> select sha2("abc", 99);
+---------------+
| sha2(abc, 99) |
+---------------+
| NULL |
+---------------+
1 row in set (0.00 sec)
```
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
| [REVERSE()](./String/reverse.md) | 将 str 字符串中的字符顺序翻转输出。|
| [RPAD()](./String/rpad.md) | 用于在字符串右侧填充|
| [RTRIM()](./String/rtrim.md) | 将输入字符串的后方空格去除|
| [SHA2()](./String/sha2.md) | 返回输入字符串的 SHA2 哈希值。|
| [SPACE()](./String/space.md) | 返回 N 个空格组成的字符串。|
| [SPLIT_PART()](./String/split_part.md) | 用于在给定的分隔符基础上将一个字符串分解成多个部分|
| [STARTSWITH()](./String/startswith.md) | 字符串如果以指定前缀开始返回 1,否则则返回 0。|
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,7 @@ nav:
- REVERSE(): MatrixOne/Reference/Functions-and-Operators/String/reverse.md
- RPAD(): MatrixOne/Reference/Functions-and-Operators/String/rpad.md
- RTRIM(): MatrixOne/Reference/Functions-and-Operators/String/rtrim.md
- SHA2(): MatrixOne/Reference/Functions-and-Operators/String/sha2.md
- SPACE(): MatrixOne/Reference/Functions-and-Operators/String/space.md
- SPLIT_PART(): MatrixOne/Reference/Functions-and-Operators/String/split_part.md
- STARTSWITH(): MatrixOne/Reference/Functions-and-Operators/String/startswith.md
Expand Down