Add BLAKE3 hash docs

This commit is contained in:
BoloniniD 2022-05-07 12:08:37 +03:00
parent d76ac4d34d
commit 0cf6f66fcf
2 changed files with 76 additions and 0 deletions

View File

@ -215,6 +215,44 @@ Result:
└──────────────────────────────────────────┘
```
## BLAKE3 {#blake3}
Calculates BLAKE3 hash string and returns the resulting set of bytes as [FixedString](../data-types/fixedstring.md).
**Syntax**
``` sql
BLAKE3('s')
```
This cryptographic hash-function is integrated into ClickHouse with BLAKE3 Rust library. The function is rather fast and shows approximately two times faster performance compared to SHA-2, while generating hashes of the same length as SHA-256.
**Arguments**
- s - input string for BLAKE3 hash calculation. [String](../data-types/string.md).
**Return value**
- BLAKE3 hash as a hex-unencoded string with type FixedString(32).
Type: [FixedString](../data-types/fixedstring.md).
**Example**
Use function [hex](../functions/encoding-functions.md#hex) to represent the result as a hex-encoded string.
Query:
``` sql
SELECT hex(BLAKE3('ABC'))
```
Result:
``` sql
┌─hex(BLAKE3('ABC'))───────────────────────────────────────────────┐
│ D1717274597CF0289694F75D96D444B992A096F1AFD8E7BBFA6EBB1D360FEDFC │
└──────────────────────────────────────────────────────────────────┘
```
## URLHash(url\[, N\]) {#urlhashurl-n}
A fast, decent-quality non-cryptographic hash function for a string obtained from a URL using some type of normalization.

View File

@ -215,6 +215,44 @@ SELECT hex(SHA1('abc'));
└──────────────────────────────────────────┘
```
## BLAKE3 {#blake3}
Вычисляет BLAKE3 хеш строки и возвращает полученный набор байт в виде [FixedString](../data-types/fixedstring.md).
**Синтаксис**
``` sql
BLAKE3('s')
```
Данная криптографическая функция интегрирована в ClickHouse из Rust-библиотеки. Функция работает сравнительно быстро, показывая в 2 раза более быстрые результаты по сравнению с SHA-2, генерируя хеши аналогичной SHA-256 длины.
**Параметры**
- s - входная строка для вычисления хеша BLAKE3. [String](../data-types/string.md).
**Возвращаемое значение**
- Хеш BLAKE3 в виде шестнадцатеричной строки, имеющей тип FixedString(32).
Тип: [FixedString](../data-types/fixedstring.md).
**Пример**
Используйте функцию [hex](../functions/encoding-functions.md#hex) для представления результата в виде строки с шестнадцатеричной кодировкой.
Запрос:
``` sql
SELECT hex(BLAKE3('ABC'))
```
Результат:
``` sql
┌─hex(BLAKE3('ABC'))───────────────────────────────────────────────┐
│ D1717274597CF0289694F75D96D444B992A096F1AFD8E7BBFA6EBB1D360FEDFC │
└──────────────────────────────────────────────────────────────────┘
```
## URLHash(url\[, N\]) {#urlhashurl-n}
Быстрая не криптографическая хэш-функция неплохого качества для строки, полученной из URL путём некоторой нормализации.