diff --git a/docs/MatrixOne/Reference/Functions-and-Operators/String/sha2.md b/docs/MatrixOne/Reference/Functions-and-Operators/String/sha2.md new file mode 100644 index 0000000000..b0a1170683 --- /dev/null +++ b/docs/MatrixOne/Reference/Functions-and-Operators/String/sha2.md @@ -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) +``` diff --git a/docs/MatrixOne/Reference/Functions-and-Operators/matrixone-function-list.md b/docs/MatrixOne/Reference/Functions-and-Operators/matrixone-function-list.md index f8bc0c3d96..14b51dc2fc 100644 --- a/docs/MatrixOne/Reference/Functions-and-Operators/matrixone-function-list.md +++ b/docs/MatrixOne/Reference/Functions-and-Operators/matrixone-function-list.md @@ -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。| diff --git a/mkdocs.yml b/mkdocs.yml index cf77ee86a5..cd70cb2210 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -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