Skip to content

Commit

Permalink
Add BLAKE3 hash docs
Browse files Browse the repository at this point in the history
  • Loading branch information
BoloniniD committed May 7, 2022
1 parent d76ac4d commit 0cf6f66
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
38 changes: 38 additions & 0 deletions docs/en/sql-reference/functions/hash-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
38 changes: 38 additions & 0 deletions docs/ru/sql-reference/functions/hash-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 путём некоторой нормализации.
Expand Down

0 comments on commit 0cf6f66

Please sign in to comment.