> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Documentation for Hash Functions

# Hash Functions

Hash functions can be used for the deterministic pseudo-random shuffling of elements.

Simhash is a hash function, which returns close hash values for close (similar) arguments.

Most hash functions accept any number of arguments of any types.

<Note>
  Hash of NULL is NULL. To get a non-NULL hash of a Nullable column, wrap it in a tuple:

  ```sql theme={null}
  SELECT cityHash64(tuple(NULL))
  ```
</Note>

<Note>
  To calculate hash of the whole contents of a table, use `sum(cityHash64(tuple(*)))` (or other hash function). `tuple` ensures that rows with NULL values are not skipped. `sum` ensures that the order of rows doesn't matter.
</Note>

{/*AUTOGENERATED_START*/}

<h2 id="BLAKE3">
  BLAKE3
</h2>

Introduced in: v22.10.0

Calculates BLAKE3 hash string and returns the resulting set of bytes as FixedString.
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.
It returns a BLAKE3 hash as a byte array with type FixedString(32).

**Syntax**

```sql theme={null}
BLAKE3(message)
```

**Arguments**

* `message` — The input string to hash. [`String`](/reference/data-types/string)

**Returned value**

Returns the 32-byte BLAKE3 hash of the input string as a fixed-length string. [`FixedString(32)`](/reference/data-types/fixedstring)

**Examples**

**hash**

```sql title=Query theme={null}
SELECT hex(BLAKE3('ABC'))
```

```response title=Response theme={null}
┌─hex(BLAKE3('ABC'))───────────────────────────────────────────────┐
│ D1717274597CF0289694F75D96D444B992A096F1AFD8E7BBFA6EBB1D360FEDFC │
└──────────────────────────────────────────────────────────────────┘
```

<h2 id="MD4">
  MD4
</h2>

Introduced in: v21.11.0

Calculates the MD4 hash of the given string.

**Syntax**

```sql theme={null}
MD4(s)
```

**Arguments**

* `s` — The input string to hash. [`String`](/reference/data-types/string)

**Returned value**

Returns the MD4 hash of the given input string as a fixed-length string. [`FixedString(16)`](/reference/data-types/fixedstring)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT HEX(MD4('abc'));
```

```response title=Response theme={null}
┌─hex(MD4('abc'))──────────────────┐
│ A448017AAF21D8525FC10AE87AA6729D │
└──────────────────────────────────┘
```

<h2 id="MD5">
  MD5
</h2>

Introduced in: v1.1.0

Calculates the MD5 hash of the given string.

**Syntax**

```sql theme={null}
MD5(s)
```

**Arguments**

* `s` — The input string to hash. [`String`](/reference/data-types/string)

**Returned value**

Returns the MD5 hash of the given input string as a fixed-length string. [`FixedString(16)`](/reference/data-types/fixedstring)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT HEX(MD5('abc'));
```

```response title=Response theme={null}
┌─hex(MD5('abc'))──────────────────┐
│ 900150983CD24FB0D6963F7D28E17F72 │
└──────────────────────────────────┘
```

<h2 id="RIPEMD160">
  RIPEMD160
</h2>

Introduced in: v24.10.0

Calculates the RIPEMD-160 hash of the given string.

**Syntax**

```sql theme={null}
RIPEMD160(s)
```

**Arguments**

* `s` — The input string to hash. [`String`](/reference/data-types/string)

**Returned value**

Returns the RIPEMD160 hash of the given input string as a fixed-length string. [`FixedString(20)`](/reference/data-types/fixedstring)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT HEX(RIPEMD160('The quick brown fox jumps over the lazy dog'));
```

```response title=Response theme={null}
┌─HEX(RIPEMD160('The quick brown fox jumps over the lazy dog'))─┐
│ 37F332F68DB77BD9D7EDD4969571AD671CF9DD3B                      │
└───────────────────────────────────────────────────────────────┘
```

<h2 id="SHA1">
  SHA1
</h2>

Introduced in: v1.1.0

Calculates the SHA1 hash of the given string.

**Syntax**

```sql theme={null}
SHA1(s)
```

**Arguments**

* `s` — The input string to hash [`String`](/reference/data-types/string)

**Returned value**

Returns the SHA1 hash of the given input string as a fixed-length string. [`FixedString(20)`](/reference/data-types/fixedstring)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT HEX(SHA1('abc'));
```

```response title=Response theme={null}
┌─hex(SHA1('abc'))─────────────────────────┐
│ A9993E364706816ABA3E25717850C26C9CD0D89D │
└──────────────────────────────────────────┘
```

<h2 id="SHA224">
  SHA224
</h2>

Introduced in: v1.1.0

Calculates the SHA224 hash of the given string.

**Syntax**

```sql theme={null}
SHA224(s)
```

**Arguments**

* `s` — The input value to hash. [`String`](/reference/data-types/string)

**Returned value**

Returns the SHA224 hash of the given input string as a fixed-length string. [`FixedString(28)`](/reference/data-types/fixedstring)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT HEX(SHA224('abc'));
```

```response title=Response theme={null}
┌─hex(SHA224('abc'))───────────────────────────────────────┐
│ 23097D223405D8228642A477BDA255B32AADBCE4BDA0B3F7E36C9DA7 │
└──────────────────────────────────────────────────────────┘
```

<h2 id="SHA256">
  SHA256
</h2>

Introduced in: v1.1.0

Calculates the SHA256 hash of the given string.

**Syntax**

```sql theme={null}
SHA256(s)
```

**Arguments**

* `s` — The input string to hash. [`String`](/reference/data-types/string)

**Returned value**

Returns the SHA256 hash of the given input string as a fixed-length string. [`FixedString(32)`](/reference/data-types/fixedstring)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT HEX(SHA256('abc'));
```

```response title=Response theme={null}
┌─hex(SHA256('abc'))───────────────────────────────────────────────┐
│ BA7816BF8F01CFEA414140DE5DAE2223B00361A396177A9CB410FF61F20015AD │
└──────────────────────────────────────────────────────────────────┘
```

<h2 id="SHA384">
  SHA384
</h2>

Introduced in: v1.1.0

Calculates the SHA384 hash of the given string.

**Syntax**

```sql theme={null}
SHA384(s)
```

**Arguments**

* `s` — The input string to hash. [`String`](/reference/data-types/string)

**Returned value**

Returns the SHA384 hash of the given input string as a fixed-length string. [`FixedString(48)`](/reference/data-types/fixedstring)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT HEX(SHA384('abc'));
```

```response title=Response theme={null}
┌─hex(SHA384('abc'))───────────────────────────────────────────────────────────────────────────────┐
│ CB00753F45A35E8BB5A03D699AC65007272C32AB0EDED1631A8B605A43FF5BED8086072BA1E7CC2358BAECA134C825A7 │
└──────────────────────────────────────────────────────────────────────────────────────────────────┘
```

<h2 id="SHA512">
  SHA512
</h2>

Introduced in: v1.1.0

Calculates the SHA512 hash of the given string.

**Syntax**

```sql theme={null}
SHA512(s)
```

**Arguments**

* `s` — The input string to hash [`String`](/reference/data-types/string)

**Returned value**

Returns the SHA512 hash of the given input string as a fixed-length string. [`FixedString(64)`](/reference/data-types/fixedstring)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT HEX(SHA512('abc'));
```

```response title=Response theme={null}
┌─hex(SHA512('abc'))───────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ DDAF35A193617ABACC417349AE20413112E6FA4E89A97EA20A9EEEE64B55D39A2192992A274FC1A836BA3C23A3FEEBBD454D4423643CE80E2A9AC94FA54CA49F │
└──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
```

<h2 id="SHA512_256">
  SHA512\_256
</h2>

Introduced in: v1.1.0

Calculates the SHA512\_256 hash of the given string.

**Syntax**

```sql theme={null}
SHA512_256(s)
```

**Arguments**

* `s` — The input string to hash. [`String`](/reference/data-types/string)

**Returned value**

Returns the SHA512\_256 hash of the given input string as a fixed-length string. [`FixedString(32)`](/reference/data-types/fixedstring)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT HEX(SHA512_256('abc'));
```

```response title=Response theme={null}
┌─hex(SHA512_256('abc'))───────────────────────────────────────────┐
│ 53048E2681941EF99B2E29B76B4C7DABE4C2D0C634FC6D46E0E2F13107E7AF23 │
└──────────────────────────────────────────────────────────────────┘
```

<h2 id="URLHash">
  URLHash
</h2>

Introduced in: v1.1.0

A fast, decent-quality non-cryptographic hash function for a string obtained from a URL using some type of normalization.

This hash function has two modes:

| Mode              | Description                                                                                                                                                                                  |
| ----------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `URLHash(url)`    | Calculates a hash from a string without one of the trailing symbols `/`,`?` or `#` at the end, if present.                                                                                   |
| `URLHash(url, N)` | Calculates a hash from a string up to the N level in the URL hierarchy, without one of the trailing symbols `/`,`?` or `#` at the end, if present. Levels are the same as in `URLHierarchy`. |

**Syntax**

```sql theme={null}
URLHash(url[, N])
```

**Arguments**

* `url` — URL string to hash. [`String`](/reference/data-types/string)
* `N` — Optional. Level in the URL hierarchy. [`(U)Int*`](/reference/data-types/int-uint)

**Returned value**

Returns the computed hash value of `url`. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT URLHash('https://www.clickhouse.com')
```

```response title=Response theme={null}
┌─URLHash('htt⋯house.com')─┐
│     13614512636072854701 │
└──────────────────────────┘
```

**Hash of url with specified level**

```sql title=Query theme={null}
SELECT URLHash('https://www.clickhouse.com/docs', 0);
SELECT URLHash('https://www.clickhouse.com/docs', 1);
```

```response title=Response theme={null}
-- hash of https://www.clickhouse.com
┌─URLHash('htt⋯m/docs', 0)─┐
│     13614512636072854701 │
└──────────────────────────┘
-- hash of https://www.clickhouse.com/docs
┌─URLHash('htt⋯m/docs', 1)─┐
│     13167253331440520598 │
└──────────────────────────┘
```

<h2 id="cityHash64">
  cityHash64
</h2>

Introduced in: v1.1.0

Produces a 64-bit [CityHash](https://github.com/google/cityhash) hash value.

This is a fast non-cryptographic hash function.
It uses the CityHash algorithm for string parameters and implementation-specific fast non-cryptographic hash function for parameters with other data types.
The function uses the CityHash combinator to get the final results.

<Info>
  Google changed the algorithm of CityHash after it was added to ClickHouse.
  In other words, ClickHouse's cityHash64 and Google's upstream CityHash now produce different results.
  ClickHouse cityHash64 corresponds to CityHash v1.0.2.
</Info>

<Note>
  The calculated hash values may be equal for the same input values of different argument types.
  This affects for example integer types of different size, named and unnamed `Tuple` with the same data, `Map` and the corresponding `Array(Tuple(key, value))` type with the same data.
</Note>

**Syntax**

```sql theme={null}
cityHash64(arg1[, arg2, ...])
```

**Arguments**

* `arg1[, arg2, ...]` — A variable number of input arguments for which to compute the hash. [`Any`](/reference/data-types/index)

**Returned value**

Returns the computed hash of the input arguments. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Call example**

```sql title=Query theme={null}
SELECT cityHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS CityHash, toTypeName(CityHash) AS type;
```

```response title=Response theme={null}
┌─────────────CityHash─┬─type───┐
│ 12072650598913549138 │ UInt64 │
└──────────────────────┴────────┘
```

**Computing the checksum of the entire table with accuracy up to the row order**

```sql title=Query theme={null}
CREATE TABLE users (
    id UInt32,
    name String,
    age UInt8,
    city String
)
ENGINE = MergeTree
ORDER BY tuple();

INSERT INTO users VALUES
(1, 'Alice', 25, 'New York'),
(2, 'Bob', 30, 'London'),
(3, 'Charlie', 35, 'Tokyo');

SELECT groupBitXor(cityHash64(*)) FROM users;
```

```response title=Response theme={null}
┌─groupBitXor(⋯age, city))─┐
│     11639977218258521182 │
└──────────────────────────┘
```

<h2 id="farmFingerprint64">
  farmFingerprint64
</h2>

Introduced in: v20.12.0

Produces a 64-bit [FarmHash](https://github.com/google/farmhash) value using the `Fingerprint64` method.

<Tip>
  `farmFingerprint64` is preferred for a stable and portable value over [`farmHash64`](#farmHash64).
</Tip>

<Note>
  The calculated hash values may be equal for the same input values of different argument types.
  This affects for example integer types of different size, named and unnamed `Tuple` with the same data, `Map` and the corresponding `Array(Tuple(key, value))` type with the same data.
</Note>

**Syntax**

```sql theme={null}
farmFingerprint64(arg1[, arg2, ...])
```

**Arguments**

* `arg1[, arg2, ...]` — A variable number of input arguments for which to compute the hash. [`Any`](/reference/data-types/index)

**Returned value**

Returns the computed hash value of the input arguments. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT farmFingerprint64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS FarmFingerprint, toTypeName(FarmFingerprint) AS type;
```

```response title=Response theme={null}
┌─────FarmFingerprint─┬─type───┐
│ 5752020380710916328 │ UInt64 │
└─────────────────────┴────────┘
```

<h2 id="farmHash64">
  farmHash64
</h2>

Introduced in: v1.1.0

Produces a 64-bit [FarmHash](https://github.com/google/farmhash) using the `Hash64` method.

<Tip>
  [`farmFingerprint64`](#farmFingerprint64) is preferred for a stable and portable value.
</Tip>

<Note>
  The calculated hash values may be equal for the same input values of different argument types.
  This affects for example integer types of different size, named and unnamed `Tuple` with the same data, `Map` and the corresponding `Array(Tuple(key, value))` type with the same data.
</Note>

**Syntax**

```sql theme={null}
farmHash64(arg1[, arg2, ...])
```

**Arguments**

* `arg1[, arg2, ...]` — A variable number of input arguments for which to compute the hash. [`Any`](/reference/data-types/index)

**Returned value**

Returns the computed hash value of the input arguments. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT farmHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS FarmHash, toTypeName(FarmHash) AS type;
```

```response title=Response theme={null}
┌─────────────FarmHash─┬─type───┐
│ 18125596431186471178 │ UInt64 │
└──────────────────────┴────────┘
```

<h2 id="gccMurmurHash">
  gccMurmurHash
</h2>

Introduced in: v20.1.0

Computes the 64-bit [MurmurHash2](https://github.com/aappleby/smhasher) hash of the input value using the same seed as used by [GCC](https://github.com/gcc-mirror/gcc/blob/41d6b10e96a1de98e90a7c0378437c3255814b16/libstdc%2B%2B-v3/include/bits/functional_hash.h#L191).

It is portable between Clang and GCC builds.

**Syntax**

```sql theme={null}
gccMurmurHash(arg1[, arg2, ...])
```

**Arguments**

* `arg1[, arg2, ...]` — A variable number of arguments for which to compute the hash. [`Any`](/reference/data-types/index)

**Returned value**

Returns the calculated hash value of the input arguments. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT
    gccMurmurHash(1, 2, 3) AS res1,
    gccMurmurHash(('a', [1, 2, 3], 4, (4, ['foo', 'bar'], 1, (1, 2)))) AS res2
```

```response title=Response theme={null}
┌─────────────────res1─┬────────────────res2─┐
│ 12384823029245979431 │ 1188926775431157506 │
└──────────────────────┴─────────────────────┘
```

<h2 id="halfMD5">
  halfMD5
</h2>

Introduced in: v1.1.0

[Interprets](/reference/functions/regular-functions/type-conversion-functions#reinterpretAsString) all the input
parameters as strings and calculates the MD5 hash value for each of them. Then combines hashes, takes the first 8 bytes of the hash of the
resulting string, and interprets them as [UInt64](/reference/data-types/int-uint) in big-endian byte order. The function is
relatively slow (5 million short strings per second per processor core).

Consider using the [`sipHash64`](#sipHash64) function instead.

The function takes a variable number of input parameters.
Arguments can be any of the supported data types.
For some data types calculated value of hash function may be the same for the same values even if types of arguments differ (integers of different size, named and unnamed Tuple with the same data, Map and the corresponding Array(Tuple(key, value)) type with the same data).

**Syntax**

```sql theme={null}
halfMD5(arg1[, arg2, ..., argN])
```

**Arguments**

* `arg1[, arg2, ..., argN]` — Variable number of arguments for which to compute the hash. [`Any`](/reference/data-types/index)

**Returned value**

Returns the computed half MD5 hash of the given input params returned as a `UInt64` in big-endian byte order. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT HEX(halfMD5('abc', 'cde', 'fgh'));
```

```response title=Response theme={null}
┌─hex(halfMD5('abc', 'cde', 'fgh'))─┐
│ 2C9506B7374CFAF4                  │
└───────────────────────────────────┘
```

<h2 id="hiveHash">
  hiveHash
</h2>

Introduced in: v20.1.0

Calculates a "HiveHash" from a string.
This is just [`JavaHash`](#javaHash) with zeroed out sign bits.
This function is used in [Apache Hive](https://en.wikipedia.org/wiki/Apache_Hive) for versions before 3.0.

<Warning>
  This hash function is unperformant.
  Use it only when this algorithm is already used in another system and you need to calculate the same result.
</Warning>

**Syntax**

```sql theme={null}
hiveHash(arg)
```

**Arguments**

* `arg` — Input string to hash. [`String`](/reference/data-types/string)

**Returned value**

Returns the computed "hive hash" of the input string. [`Int32`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT hiveHash('Hello, world!');
```

```response title=Response theme={null}
┌─hiveHash('Hello, world!')─┐
│                 267439093 │
└───────────────────────────┘
```

<h2 id="icebergHash">
  icebergHash
</h2>

Introduced in: v25.5.0

Implements the logic of the iceberg [hashing transform](https://iceberg.apache.org/spec/#appendix-b-32-bit-hash-requirements)

**Syntax**

```sql theme={null}
icebergHash(value)
```

**Arguments**

* `value` — Source value to take the hash of [`Integer`](/reference/data-types/int-uint) or [`Bool`](/reference/data-types/boolean) or [`Decimal`](/reference/data-types/decimal) or [`Float*`](/reference/data-types/float) or [`String`](/reference/data-types/string) or [`FixedString`](/reference/data-types/fixedstring) or [`UUID`](/reference/data-types/uuid) or [`Date`](/reference/data-types/date) or [`Time`](/reference/data-types/time) or [`DateTime`](/reference/data-types/datetime)

**Returned value**

Returns a 32-bit Murmur3 hash, x86 variant, seeded with 0 [`Int32`](/reference/data-types/int-uint)

**Examples**

**Example**

```sql title=Query theme={null}
SELECT icebergHash(1.0 :: Float32)
```

```response title=Response theme={null}
-142385009
```

<h2 id="intHash32">
  intHash32
</h2>

Introduced in: v1.1.0

Calculates a 32-bit hash of an integer.

The hash function is relatively fast but not cryptographic hash function.

**Syntax**

```sql theme={null}
intHash32(arg)
```

**Arguments**

* `arg` — Integer to hash. [`(U)Int*`](/reference/data-types/int-uint)

**Returned value**

Returns the computed 32-bit hash code of the input integer [`UInt32`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT intHash32(42);
```

```response title=Response theme={null}
┌─intHash32(42)─┐
│    1228623923 │
└───────────────┘
```

<h2 id="intHash64">
  intHash64
</h2>

Introduced in: v1.1.0

Calculates a 64-bit hash of an integer.

The hash function is relatively fast (even faster than [`intHash32`](#intHash32)) but not a cryptographic hash function.

**Syntax**

```sql theme={null}
intHash64(int)
```

**Arguments**

* `int` — Integer to hash. [`(U)Int*`](/reference/data-types/int-uint)

**Returned value**

64-bit hash code. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT intHash64(42);
```

```response title=Response theme={null}
┌────────intHash64(42)─┐
│ 11490350930367293593 │
└──────────────────────┘
```

<h2 id="javaHash">
  javaHash
</h2>

Introduced in: v20.1.0

Calculates JavaHash from:

* [string](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452),
* [Byte](https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/Byte.java#l405),
* [Short](https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/Short.java#l410),
* [Integer](https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/Integer.java#l959),
* [Long](https://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/Long.java#l1060).

<Warning>
  This hash function is unperformant.
  Use it only when this algorithm is already in use in another system and you need to calculate the same result.
</Warning>

<Note>
  Java only supports calculating the hash of signed integers,
  so if you want to calculate a hash of unsigned integers you must cast them to the proper signed ClickHouse types.
</Note>

**Syntax**

```sql theme={null}
javaHash(arg)
```

**Arguments**

* `arg` — Input value to hash. [`Any`](/reference/data-types/index)

**Returned value**

Returns the computed hash of `arg` [`Int32`](/reference/data-types/int-uint)

**Examples**

**Usage example 1**

```sql title=Query theme={null}
SELECT javaHash(toInt32(123));
```

```response title=Response theme={null}
┌─javaHash(toInt32(123))─┐
│               123      │
└────────────────────────┘
```

**Usage example 2**

```sql title=Query theme={null}
SELECT javaHash('Hello, world!');
```

```response title=Response theme={null}
┌─javaHash('Hello, world!')─┐
│               -1880044555 │
└───────────────────────────┘
```

<h2 id="javaHashUTF16LE">
  javaHashUTF16LE
</h2>

Introduced in: v20.1.0

Calculates [JavaHash](http://hg.openjdk.java.net/jdk8u/jdk8u/jdk/file/478a4add975b/src/share/classes/java/lang/String.java#l1452) from a string, assuming it contains bytes representing a string in UTF-16LE encoding.

**Syntax**

```sql theme={null}
javaHashUTF16LE(arg)
```

**Arguments**

* `arg` — A string in UTF-16LE encoding. [`String`](/reference/data-types/string)

**Returned value**

Returns the computed hash of the UTF-16LE encoded string. [`Int32`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le'));
```

```response title=Response theme={null}
┌─javaHashUTF16LE(convertCharset('test', 'utf-8', 'utf-16le'))─┐
│                                                      3556498 │
└──────────────────────────────────────────────────────────────┘
```

<h2 id="jumpConsistentHash">
  jumpConsistentHash
</h2>

Introduced in: v1.1.0

Calculates the [jump consistent hash](https://arxiv.org/pdf/1406.2294.pdf) for an integer.

**Syntax**

```sql theme={null}
jumpConsistentHash(key, buckets)
```

**Arguments**

* `key` — The input key. [`UInt64`](/reference/data-types/int-uint)
* `buckets` — The number of buckets. [`Int32`](/reference/data-types/int-uint)

**Returned value**

Returns the computed hash value. [`Int32`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT jumpConsistentHash(256, 4)
```

```response title=Response theme={null}
┌─jumpConsistentHash(256, 4)─┐
│                          3 │
└────────────────────────────┘
```

<h2 id="kafkaMurmurHash">
  kafkaMurmurHash
</h2>

Introduced in: v23.4.0

Calculates the 32-bit [MurmurHash2](https://github.com/aappleby/smhasher) hash of the input value using the same seed as used by [Kafka](https://github.com/apache/kafka/blob/461c5cfe056db0951d9b74f5adc45973670404d7/clients/src/main/java/org/apache/kafka/common/utils/Utils.java#L482) and without the highest bit to be compatible with [Default Partitioner](https://github.com/apache/kafka/blob/139f7709bd3f5926901a21e55043388728ccca78/clients/src/main/java/org/apache/kafka/clients/producer/internals/BuiltInPartitioner.java#L328).

**Syntax**

```sql theme={null}
kafkaMurmurHash(arg1[, arg2, ...])
```

**Arguments**

* `arg1[, arg2, ...]` — A variable number of parameters for which to compute the hash. [`Any`](/reference/data-types/index)

**Returned value**

Returns the calculated hash value of the input arguments. [`UInt32`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT
    kafkaMurmurHash('foobar') AS res1,
    kafkaMurmurHash(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS res2
```

```response title=Response theme={null}
┌───────res1─┬─────res2─┐
│ 1357151166 │ 85479775 │
└────────────┴──────────┘
```

<h2 id="keccak256">
  keccak256
</h2>

Introduced in: v25.4.0

Calculates the Keccak-256 cryptographic hash of the given string.
This hash function is widely used in blockchain applications, particularly Ethereum.

**Syntax**

```sql theme={null}
keccak256(message)
```

**Arguments**

* `message` — The input string to hash. [`String`](/reference/data-types/string)

**Returned value**

Returns the 32-byte Keccak-256 hash of the input string as a fixed-length string. [`FixedString(32)`](/reference/data-types/fixedstring)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT hex(keccak256('hello'))
```

```response title=Response theme={null}
┌─hex(keccak256('hello'))──────────────────────────────────────────┐
│ 1C8AFF950685C2ED4BC3174F3472287B56D9517B9C948127319A09A7A36DEAC8 │
└──────────────────────────────────────────────────────────────────┘
```

<h2 id="kostikConsistentHash">
  kostikConsistentHash
</h2>

Introduced in: v22.6.0

An O(1) time and space consistent hash algorithm by Konstantin 'Kostik' Oblakov.
Only efficient with `n <= 32768`.

**Syntax**

```sql theme={null}
kostikConsistentHash(input, n)
```

**Aliases**: `yandexConsistentHash`

**Arguments**

* `input` — An integer key. [`UInt64`](/reference/data-types/int-uint)
* `n` — The number of buckets. [`UInt16`](/reference/data-types/int-uint)

**Returned value**

Returns the computed hash value. [`UInt16`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT kostikConsistentHash(16045690984833335023, 2);
```

```response title=Response theme={null}
┌─kostikConsistentHash(16045690984833335023, 2)─┐
│                                             1 │
└───────────────────────────────────────────────┘
```

<h2 id="metroHash64">
  metroHash64
</h2>

Introduced in: v1.1.0

Produces a 64-bit [MetroHash](http://www.jandrewrogers.com/2015/05/27/metrohash/) hash value.

<Note>
  The calculated hash values may be equal for the same input values of different argument types.
  This affects for example integer types of different size, named and unnamed `Tuple` with the same data, `Map` and the corresponding `Array(Tuple(key, value))` type with the same data.
</Note>

**Syntax**

```sql theme={null}
metroHash64(arg1[, arg2, ...])
```

**Arguments**

* `arg1[, arg2, ...]` — A variable number of input arguments for which to compute the hash. [`Any`](/reference/data-types/index)

**Returned value**

Returns the computed hash of the input arguments. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT metroHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MetroHash, toTypeName(MetroHash) AS type;
```

```response title=Response theme={null}
┌────────────MetroHash─┬─type───┐
│ 14235658766382344533 │ UInt64 │
└──────────────────────┴────────┘
```

<h2 id="murmurHash2_32">
  murmurHash2\_32
</h2>

Introduced in: v18.5.0

Computes the [MurmurHash2](https://github.com/aappleby/smhasher) hash of the input value.

<Note>
  The calculated hash values may be equal for the same input values of different argument types.
  This affects for example integer types of different size, named and unnamed `Tuple` with the same data, `Map` and the corresponding `Array(Tuple(key, value))` type with the same data.
</Note>

**Syntax**

```sql theme={null}
murmurHash2_32(arg1[, arg2, ...])
```

**Arguments**

* `arg1[, arg2, ...]` — A variable number of input arguments for which to compute the hash. [`Any`](/reference/data-types/index)

**Returned value**

Returns the computed hash value of the input arguments. [`UInt32`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT murmurHash2_32(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash2, toTypeName(MurmurHash2) AS type;
```

```response title=Response theme={null}
┌─MurmurHash2─┬─type───┐
│  3681770635 │ UInt32 │
└─────────────┴────────┘
```

<h2 id="murmurHash2_64">
  murmurHash2\_64
</h2>

Introduced in: v18.10.0

Computes the [MurmurHash2](https://github.com/aappleby/smhasher) hash of the input value.

<Note>
  The calculated hash values may be equal for the same input values of different argument types.
  This affects for example integer types of different size, named and unnamed `Tuple` with the same data, `Map` and the corresponding `Array(Tuple(key, value))` type with the same data.
</Note>

**Syntax**

```sql theme={null}
murmurHash2_64(arg1[, arg2, ...])
```

**Arguments**

* `arg1[, arg2, ...]` — A variable number of input arguments for which to compute the hash. [`Any`](/reference/data-types/index)

**Returned value**

Returns the computed hash of the input arguments. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT murmurHash2_64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash2, toTypeName(MurmurHash2) AS type;
```

```response title=Response theme={null}
┌──────────MurmurHash2─┬─type───┐
│ 11832096901709403633 │ UInt64 │
└──────────────────────┴────────┘
```

<h2 id="murmurHash3_128">
  murmurHash3\_128
</h2>

Introduced in: v18.10.0

Computes the 128-bit [MurmurHash3](https://github.com/aappleby/smhasher) hash of the input value.

**Syntax**

```sql theme={null}
murmurHash3_128(arg1[, arg2, ...])
```

**Arguments**

* `arg1[, arg2, ...]` — A variable number of input arguments for which to compute the hash. [`Any`](/reference/data-types/index)

**Returned value**

Returns the computed 128-bit `MurmurHash3` hash value of the input arguments. [`FixedString(16)`](/reference/data-types/fixedstring)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT hex(murmurHash3_128('foo', 'foo', 'foo'));
```

```response title=Response theme={null}
┌─hex(murmurHash3_128('foo', 'foo', 'foo'))─┐
│ F8F7AD9B6CD4CF117A71E277E2EC2931          │
└───────────────────────────────────────────┘
```

<h2 id="murmurHash3_32">
  murmurHash3\_32
</h2>

Introduced in: v18.10.0

Produces a [MurmurHash3](https://github.com/aappleby/smhasher) hash value.

<Note>
  The calculated hash values may be equal for the same input values of different argument types.
  This affects for example integer types of different size, named and unnamed `Tuple` with the same data, `Map` and the corresponding `Array(Tuple(key, value))` type with the same data.
</Note>

**Syntax**

```sql theme={null}
murmurHash3_32(arg1[, arg2, ...])
```

**Arguments**

* `arg1[, arg2, ...]` — A variable number of input arguments for which to compute the hash. [`Any`](/reference/data-types/index)

**Returned value**

Returns the computed hash value of the input arguments. [`UInt32`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT murmurHash3_32(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash3, toTypeName(MurmurHash3) AS type;
```

```response title=Response theme={null}
┌─MurmurHash3─┬─type───┐
│     2152717 │ UInt32 │
└─────────────┴────────┘
```

<h2 id="murmurHash3_64">
  murmurHash3\_64
</h2>

Introduced in: v18.10.0

Computes the [MurmurHash3](https://github.com/aappleby/smhasher) hash of the input value.

<Note>
  The calculated hash values may be equal for the same input values of different argument types.
  This affects for example integer types of different size, named and unnamed `Tuple` with the same data, `Map` and the corresponding `Array(Tuple(key, value))` type with the same data.
</Note>

**Syntax**

```sql theme={null}
murmurHash3_64(arg1[, arg2, ...])
```

**Arguments**

* `arg1[, arg2, ...]` — A variable number of input arguments for which to compute the hash. [`Any`](/reference/data-types/index)

**Returned value**

Returns the computed hash value of the input arguments. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT murmurHash3_64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS MurmurHash3, toTypeName(MurmurHash3) AS type;
```

```response title=Response theme={null}
┌──────────MurmurHash3─┬─type───┐
│ 11832096901709403633 │ UInt64 │
└──────────────────────┴────────┘
```

<h2 id="ngramMinHash">
  ngramMinHash
</h2>

Introduced in: v21.1.0

Splits a ASCII string into n-grams of `ngramsize` symbols and calculates hash values for each n-gram and returns a tuple with these hashes.
Uses `hashnum` minimum hashes to calculate the minimum hash and `hashnum` maximum hashes to calculate the maximum hash.
It is case sensitive.

Can be used to detect semi-duplicate strings with [`tupleHammingDistance`](/reference/functions/regular-functions/tuple-functions#tupleHammingDistance).
For two strings, if the returned hashes are the same for both strings, then those strings are the same.

**Syntax**

```sql theme={null}
ngramMinHash(string[, ngramsize, hashnum])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `ngramsize` — Optional. The size of an n-gram, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)
* `hashnum` — Optional. The number of minimum and maximum hashes used to calculate the result, any number from `1` to `25`. The default value is `6`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns a tuple with two hashes — the minimum and the maximum. [`Tuple`](/reference/data-types/tuple)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT ngramMinHash('ClickHouse') AS Tuple;
```

```response title=Response theme={null}
┌─Tuple──────────────────────────────────────┐
│ (18333312859352735453,9054248444481805918) │
└────────────────────────────────────────────┘
```

<h2 id="ngramMinHashArg">
  ngramMinHashArg
</h2>

Introduced in: v21.1.0

Splits a ASCII string into n-grams of `ngramsize` symbols and returns the n-grams with minimum and maximum hashes, calculated by the [`ngramMinHash`](#ngramMinHash) function with the same input.
It is case sensitive.

**Syntax**

```sql theme={null}
ngramMinHashArg(string[, ngramsize, hashnum])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `ngramsize` — Optional. The size of an n-gram, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)
* `hashnum` — Optional. The number of minimum and maximum hashes used to calculate the result, any number from `1` to `25`. The default value is `6`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns a tuple with two tuples with `hashnum` n-grams each. [`Tuple(String)`](/reference/data-types/tuple)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT ngramMinHashArg('ClickHouse') AS Tuple;
```

```response title=Response theme={null}
┌─Tuple─────────────────────────────────────────────────────────────────────────┐
│ (('ous','ick','lic','Hou','kHo','use'),('Hou','lic','ick','ous','ckH','Cli')) │
└───────────────────────────────────────────────────────────────────────────────┘
```

<h2 id="ngramMinHashArgCaseInsensitive">
  ngramMinHashArgCaseInsensitive
</h2>

Introduced in: v21.1.0

Splits a ASCII string into n-grams of `ngramsize` symbols and returns the n-grams with minimum and maximum hashes, calculated by the [`ngramMinHashCaseInsensitive`](#ngramMinHashCaseInsensitive) function with the same input.
It is case insensitive.

**Syntax**

```sql theme={null}
ngramMinHashArgCaseInsensitive(string[, ngramsize, hashnum])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `ngramsize` — Optional. The size of an n-gram, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)
* `hashnum` — Optional. The number of minimum and maximum hashes used to calculate the result, any number from `1` to `25`. The default value is `6`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns a tuple with two tuples with `hashnum` n-grams each. [`Tuple(Tuple(String))`](/reference/data-types/tuple)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT ngramMinHashArgCaseInsensitive('ClickHouse') AS Tuple;
```

```response title=Response theme={null}
┌─Tuple─────────────────────────────────────────────────────────────────────────┐
│ (('ous','ick','lic','kHo','use','Cli'),('kHo','lic','ick','ous','ckH','Hou')) │
└───────────────────────────────────────────────────────────────────────────────┘
```

<h2 id="ngramMinHashArgCaseInsensitiveUTF8">
  ngramMinHashArgCaseInsensitiveUTF8
</h2>

Introduced in: v21.1.0

Splits a UTF-8 string into n-grams of `ngramsize` symbols and returns the n-grams with minimum and maximum hashes, calculated by the ngramMinHashCaseInsensitiveUTF8 function with the same input.
It is case insensitive.

**Syntax**

```sql theme={null}
ngramMinHashArgCaseInsensitiveUTF8(string[, ngramsize, hashnum])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `ngramsize` — Optional. The size of an n-gram, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)
* `hashnum` — Optional. The number of minimum and maximum hashes used to calculate the result, any number from `1` to `25`. The default value is `6`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns a tuple with two tuples with `hashnum` n-grams each. [`Tuple(Tuple(String))`](/reference/data-types/tuple)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT ngramMinHashArgCaseInsensitiveUTF8('ClickHouse') AS Tuple;
```

```response title=Response theme={null}
┌─Tuple─────────────────────────────────────────────────────────────────────────┐
│ (('ckH','ous','ick','lic','kHo','use'),('kHo','lic','ick','ous','ckH','Hou')) │
└───────────────────────────────────────────────────────────────────────────────┘
```

<h2 id="ngramMinHashArgUTF8">
  ngramMinHashArgUTF8
</h2>

Introduced in: v21.1.0

Splits a UTF-8 string into n-grams of `ngramsize` symbols and returns the n-grams with minimum and maximum hashes, calculated by the `ngramMinHashUTF8` function with the same input.
It is case sensitive.

**Syntax**

```sql theme={null}
ngramMinHashArgUTF8(string[, ngramsize, hashnum])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `ngramsize` — Optional. The size of an n-gram, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)
* `hashnum` — Optional. The number of minimum and maximum hashes used to calculate the result, any number from `1` to `25`. The default value is `6`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns a tuple with two tuples with `hashnum` n-grams each. [`Tuple(Tuple(String))`](/reference/data-types/tuple)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT ngramMinHashArgUTF8('ClickHouse') AS Tuple;
```

```response title=Response theme={null}
┌─Tuple─────────────────────────────────────────────────────────────────────────┐
│ (('ous','ick','lic','Hou','kHo','use'),('kHo','Hou','lic','ick','ous','ckH')) │
└───────────────────────────────────────────────────────────────────────────────┘
```

<h2 id="ngramMinHashCaseInsensitive">
  ngramMinHashCaseInsensitive
</h2>

Introduced in: v21.1.0

Splits a ASCII string into n-grams of `ngramsize` symbols and calculates hash values for each n-gram and returns a tuple with these hashes
Uses `hashnum` minimum hashes to calculate the minimum hash and `hashnum` maximum hashes to calculate the maximum hash.
It is case insensitive.

Can be used to detect semi-duplicate strings with [`tupleHammingDistance`](/reference/functions/regular-functions/tuple-functions#tupleHammingDistance).
For two strings, if the returned hashes are the same for both strings, then those strings are the same.

**Syntax**

```sql theme={null}
ngramMinHashCaseInsensitive(string[, ngramsize, hashnum])
```

**Arguments**

* `string` — String. [String](/reference/data-types/string). - `ngramsize` — The size of an n-gram. Optional. Possible values: any number from `1` to `25`. Default value: `3`. [UInt8](/reference/data-types/int-uint). - `hashnum` — The number of minimum and maximum hashes used to calculate the result. Optional. Possible values: any number from `1` to `25`. Default value: `6`. [UInt8](/reference/data-types/int-uint).

**Returned value**

Tuple with two hashes — the minimum and the maximum. [Tuple](/reference/data-types/tuple)([UInt64](/reference/data-types/int-uint), [UInt64](/reference/data-types/int-uint)). [`Tuple`](/reference/data-types/tuple)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT ngramMinHashCaseInsensitive('ClickHouse') AS Tuple;
```

```response title=Response theme={null}
┌─Tuple──────────────────────────────────────┐
│ (2106263556442004574,13203602793651726206) │
└────────────────────────────────────────────┘
```

<h2 id="ngramMinHashCaseInsensitiveUTF8">
  ngramMinHashCaseInsensitiveUTF8
</h2>

Introduced in: v21.1.0

Splits a UTF-8 string into n-grams of `ngramsize` symbols and calculates hash values for each n-gram and returns a tuple with these hashes..
Uses `hashnum` minimum hashes to calculate the minimum hash and `hashnum` maximum hashes to calculate the maximum hash.
It is case insensitive.

Can be used to detect semi-duplicate strings with [`tupleHammingDistance`](/reference/functions/regular-functions/tuple-functions#tupleHammingDistance).
For two strings, if the returned hashes are the same for both strings, then those strings are the same.

**Syntax**

```sql theme={null}
ngramMinHashCaseInsensitiveUTF8(string [, ngramsize, hashnum])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `ngramsize` — Optional. The size of an n-gram, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)
* `hashnum` — Optional. The number of minimum and maximum hashes used to calculate the result, any number from `1` to `25`. The default value is `6`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns a tuple with two hashes — the minimum and the maximum. [`Tuple`](/reference/data-types/tuple)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT ngramMinHashCaseInsensitiveUTF8('ClickHouse') AS Tuple;
```

```response title=Response theme={null}
┌─Tuple───────────────────────────────────────┐
│ (12493625717655877135,13203602793651726206) │
└─────────────────────────────────────────────┘
```

<h2 id="ngramMinHashUTF8">
  ngramMinHashUTF8
</h2>

Introduced in: v21.1.0

Splits a UTF-8 string into n-grams of `ngramsize` symbols and calculates hash values for each n-gram and returns a tuple with these hashes.
Uses `hashnum` minimum hashes to calculate the minimum hash and `hashnum` maximum hashes to calculate the maximum hash.
It is case sensitive.

Can be used to detect semi-duplicate strings with [`tupleHammingDistance`](/reference/functions/regular-functions/tuple-functions#tupleHammingDistance).
For two strings, if the returned hashes are the same for both strings, then those strings are the same.

**Syntax**

```sql theme={null}
ngramMinHashUTF8(string[, ngramsize, hashnum])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `ngramsize` — Optional. The size of an n-gram, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)
* `hashnum` — Optional. The number of minimum and maximum hashes used to calculate the result, any number from `1` to `25`. The default value is `6`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns a tuple with two hashes — the minimum and the maximum. [`Tuple`](/reference/data-types/tuple)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT ngramMinHashUTF8('ClickHouse') AS Tuple;
```

```response title=Response theme={null}
┌─Tuple──────────────────────────────────────┐
│ (18333312859352735453,6742163577938632877) │
└────────────────────────────────────────────┘
```

<h2 id="ngramSimHash">
  ngramSimHash
</h2>

Introduced in: v21.1.0

Splits a ASCII string into n-grams of `ngramsize` symbols and returns the n-gram `simhash`.

Can be used for detection of semi-duplicate strings with [`bitHammingDistance`](/reference/functions/regular-functions/bit-functions#bitHammingDistance).
The smaller the [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) of the calculated `simhashes` of two strings, the more likely these strings are the same.

**Syntax**

```sql theme={null}
ngramSimHash(string[, ngramsize])
```

**Arguments**

* `string` — String for which to compute the case sensitive `simhash`. [`String`](/reference/data-types/string)
* `ngramsize` — Optional. The size of an n-gram, any number from `1` to `25`. The default value is`3`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns the computed hash of the input string. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT ngramSimHash('ClickHouse') AS Hash;
```

```response title=Response theme={null}
┌───────Hash─┐
│ 1627567969 │
└────────────┘
```

<h2 id="ngramSimHashCaseInsensitive">
  ngramSimHashCaseInsensitive
</h2>

Introduced in: v21.1.0

Splits a ASCII string into n-grams of `ngramsize` symbols and returns the n-gram `simhash`.
It is case insensitive.

Can be used for detection of semi-duplicate strings with [`bitHammingDistance`](/reference/functions/regular-functions/bit-functions#bitHammingDistance).
The smaller the [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) of the calculated `simhashes` of two strings, the more likely these strings are the same.

**Syntax**

```sql theme={null}
ngramSimHashCaseInsensitive(string[, ngramsize])
```

**Arguments**

* `string` — String for which to compute the case insensitive `simhash`. [`String`](/reference/data-types/string)
* `ngramsize` — Optional. The size of an n-gram, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Hash value. [UInt64](/reference/data-types/int-uint). [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT ngramSimHashCaseInsensitive('ClickHouse') AS Hash;
```

```response title=Response theme={null}
┌──────Hash─┐
│ 562180645 │
└───────────┘
```

<h2 id="ngramSimHashCaseInsensitiveUTF8">
  ngramSimHashCaseInsensitiveUTF8
</h2>

Introduced in: v21.1.0

Splits a UTF-8 string into n-grams of `ngramsize` symbols and returns the n-gram `simhash`.
It is case insensitive.

Can be used for detection of semi-duplicate strings with [bitHammingDistance](/reference/functions/regular-functions/bit-functions#bitHammingDistance). The smaller is the [Hamming Distance](https://en.wikipedia.org/wiki/Hamming_distance) of the calculated `simhashes` of two strings, the more likely these strings are the same.

**Syntax**

```sql theme={null}
ngramSimHashCaseInsensitiveUTF8(string[, ngramsize])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `ngramsize` — Optional. The size of an n-gram, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns the computed hash value. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT ngramSimHashCaseInsensitiveUTF8('ClickHouse') AS Hash;
```

```response title=Response theme={null}
┌───────Hash─┐
│ 1636742693 │
└────────────┘
```

<h2 id="ngramSimHashUTF8">
  ngramSimHashUTF8
</h2>

Introduced in: v21.1.0

Splits a UTF-8 encoded string into n-grams of `ngramsize` symbols and returns the n-gram `simhash`.
It is case sensitive.

Can be used for detection of semi-duplicate strings with [`bitHammingDistance`](/reference/functions/regular-functions/bit-functions#bitHammingDistance).
The smaller the [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) of the calculated `simhashes` of two strings, the more likely these strings are the same.

**Syntax**

```sql theme={null}
ngramSimHashUTF8(string[, ngramsize])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `ngramsize` — Optional. The size of an n-gram, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns the computed hash value. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT ngramSimHashUTF8('ClickHouse') AS Hash;
```

```response title=Response theme={null}
┌───────Hash─┐
│ 1628157797 │
└────────────┘
```

<h2 id="sipHash128">
  sipHash128
</h2>

Introduced in: v1.1.0

Like [`sipHash64`](#sipHash64) but produces a 128-bit hash value, i.e. the final xor-folding state is done up to 128 bits.

<Tip>
  **use sipHash128Reference for new projects**

  This 128-bit variant differs from the reference implementation and is weaker.
  This version exists because, when it was written, there was no official 128-bit extension for SipHash.
  New projects are advised to use [`sipHash128Reference`](#sipHash128Reference).
</Tip>

**Syntax**

```sql theme={null}
sipHash128(arg1[, arg2, ...])
```

**Arguments**

* `arg1[, arg2, ...]` — A variable number of input arguments for which to compute the hash. [`Any`](/reference/data-types/index)

**Returned value**

Returns a 128-bit `SipHash` hash value. [`FixedString(16)`](/reference/data-types/fixedstring)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT hex(sipHash128('foo', '\x01', 3));
```

```response title=Response theme={null}
┌─hex(sipHash128('foo', '', 3))────┐
│ 9DE516A64A414D4B1B609415E4523F24 │
└──────────────────────────────────┘
```

<h2 id="sipHash128Keyed">
  sipHash128Keyed
</h2>

Introduced in: v23.2.0

Same as [`sipHash128`](#sipHash128) but additionally takes an explicit key argument instead of using a fixed key.

<Tip>
  **use sipHash128ReferenceKeyed for new projects**

  This 128-bit variant differs from the reference implementation and it's weaker.
  This version exists because, when it was written, there was no official 128-bit extension for SipHash.
  New projects should probably use [`sipHash128ReferenceKeyed`](#sipHash128ReferenceKeyed).
</Tip>

**Syntax**

```sql theme={null}
sipHash128Keyed((k0, k1), [arg1, arg2, ...])
```

**Arguments**

* `(k0, k1)` — A tuple of two UInt64 values representing the key. [`Tuple(UInt64, UInt64)`](/reference/data-types/tuple)
* `arg1[, arg2, ...]` — A variable number of input arguments for which to compute the hash. [`Any`](/reference/data-types/index)

**Returned value**

A 128-bit `SipHash` hash value of type [FixedString(16)](/reference/data-types/fixedstring). [`FixedString(16)`](/reference/data-types/fixedstring)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT hex(sipHash128Keyed((506097522914230528, 1084818905618843912),'foo', '\x01', 3));
```

```response title=Response theme={null}
┌─hex(sipHash128Keyed((506097522914230528, 1084818905618843912), 'foo', '', 3))─┐
│ B8467F65C8B4CFD9A5F8BD733917D9BF                                              │
└───────────────────────────────────────────────────────────────────────────────┘
```

<h2 id="sipHash128Reference">
  sipHash128Reference
</h2>

Introduced in: v23.2.0

Like [`sipHash128`](/reference/functions/regular-functions/hash-functions#sipHash128) but implements the 128-bit algorithm from the original authors of SipHash.

**Syntax**

```sql theme={null}
sipHash128Reference(arg1[, arg2, ...])
```

**Arguments**

* `arg1[, arg2, ...]` — A variable number of input arguments for which to compute the hash. [`Any`](/reference/data-types/index)

**Returned value**

Returns the computed 128-bit `SipHash` hash value of the input arguments. [`FixedString(16)`](/reference/data-types/fixedstring)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT hex(sipHash128Reference('foo', '', 3));
```

```response title=Response theme={null}
┌─hex(sipHash128Reference('foo', '', 3))─┐
│ 4D1BE1A22D7F5933C0873E1698426260       │
└────────────────────────────────────────┘
```

<h2 id="sipHash128ReferenceKeyed">
  sipHash128ReferenceKeyed
</h2>

Introduced in: v23.2.0

Same as [`sipHash128Reference`](#sipHash128Reference) but additionally takes an explicit key argument instead of using a fixed key.

**Syntax**

```sql theme={null}
sipHash128ReferenceKeyed((k0, k1), arg1[, arg2, ...])
```

**Arguments**

* `(k0, k1)` — Tuple of two values representing the key [`Tuple(UInt64, UInt64)`](/reference/data-types/tuple)
* `arg1[, arg2, ...]` — A variable number of input arguments for which to compute the hash. [`Any`](/reference/data-types/index)

**Returned value**

Returns the computed 128-bit `SipHash` hash value of the input arguments. [`FixedString(16)`](/reference/data-types/fixedstring)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT hex(sipHash128Reference('foo', '', 3));
```

```response title=Response theme={null}
┌─hex(sipHash128Reference('foo', '', 3))─┐
│ 4D1BE1A22D7F5933C0873E1698426260       │
└────────────────────────────────────────┘
```

<h2 id="sipHash64">
  sipHash64
</h2>

Introduced in: v1.1.0

Produces a 64-bit [SipHash](https://en.wikipedia.org/wiki/SipHash) hash value.

This is a cryptographic hash function. It works at least three times faster than the [`MD5`](#MD5) hash function.

The function [interprets](/reference/functions/regular-functions/type-conversion-functions#reinterpretAsString) all the input parameters as strings and calculates the hash value for each of them.
It then combines the hashes using the following algorithm:

1. The first and the second hash value are concatenated to an array which is hashed.
2. The previously calculated hash value and the hash of the third input parameter are hashed in a similar way.
3. This calculation is repeated for all remaining hash values of the original input.

<Note>
  the calculated hash values may be equal for the same input values of different argument types.
  This affects for example integer types of different size, named and unnamed `Tuple` with the same data, `Map` and the corresponding `Array(Tuple(key, value))` type with the same data.
</Note>

**Syntax**

```sql theme={null}
sipHash64(arg1[, arg2, ...])
```

**Arguments**

* `arg1[, arg2, ...]` — A variable number of input arguments. [`Any`](/reference/data-types/index)

**Returned value**

Returns a computed hash value of the input arguments. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT sipHash64(array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS SipHash, toTypeName(SipHash) AS type;
```

```response title=Response theme={null}
┌──────────────SipHash─┬─type───┐
│ 11400366955626497465 │ UInt64 │
└──────────────────────┴────────┘
```

<h2 id="sipHash64Keyed">
  sipHash64Keyed
</h2>

Introduced in: v23.2.0

Like [`sipHash64`](#sipHash64) but additionally takes an explicit key argument instead of using a fixed key.

**Syntax**

```sql theme={null}
sipHash64Keyed((k0, k1), arg1[,arg2, ...])
```

**Arguments**

* `(k0, k1)` — A tuple of two values representing the key. [`Tuple(UInt64, UInt64)`](/reference/data-types/tuple)
* `arg1[,arg2, ...]` — A variable number of input arguments. [`Any`](/reference/data-types/index)

**Returned value**

Returns the computed hash of the input values. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT sipHash64Keyed((506097522914230528, 1084818905618843912), array('e','x','a'), 'mple', 10, toDateTime('2019-06-15 23:00:00')) AS SipHash, toTypeName(SipHash) AS type;
```

```response title=Response theme={null}
┌─────────────SipHash─┬─type───┐
│ 8017656310194184311 │ UInt64 │
└─────────────────────┴────────┘
```

<h2 id="wordShingleMinHash">
  wordShingleMinHash
</h2>

Introduced in: v21.1.0

Splits a ASCII string into parts (shingles) of `shinglesize` words, calculates hash values for each word shingle and returns a tuple with these hashes.
Uses `hashnum` minimum hashes to calculate the minimum hash and `hashnum` maximum hashes to calculate the maximum hash.
It is case sensitive.

Can be used to detect semi-duplicate strings with [`tupleHammingDistance`](/reference/functions/regular-functions/tuple-functions#tupleHammingDistance).
For two strings, if the returned hashes are the same for both strings, then those strings are the same.

**Syntax**

```sql theme={null}
wordShingleMinHash(string[, shinglesize, hashnum])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `shinglesize` — Optional. The size of a word shingle, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)
* `hashnum` — Optional. The number of minimum and maximum hashes used to calculate the result, any number from `1` to `25`. The default value is `6`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns a tuple with two hashes — the minimum and the maximum. [`Tuple(UInt64, UInt64)`](/reference/data-types/tuple)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT wordShingleMinHash('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Tuple;
```

```response title=Response theme={null}
┌─Tuple──────────────────────────────────────┐
│ (16452112859864147620,5844417301642981317) │
└────────────────────────────────────────────┘
```

<h2 id="wordShingleMinHashArg">
  wordShingleMinHashArg
</h2>

Introduced in: v1.1.0

Splits a ASCII string into parts (shingles) of `shinglesize` words each and returns the shingles with minimum and maximum word hashes, calculated by the wordShingleMinHash function with the same input.
It is case sensitive.

**Syntax**

```sql theme={null}
wordShingleMinHashArg(string[, shinglesize, hashnum])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `shinglesize` — Optional. The size of a word shingle, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)
* `hashnum` — Optional. The number of minimum and maximum hashes used to calculate the result, any number from `1` to `25`. The default value is `6`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns a tuple with two tuples with `hashnum` word shingles each. [`Tuple(Tuple(String))`](/reference/data-types/tuple)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT wordShingleMinHashArg('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).', 1, 3) AS Tuple;
```

```response title=Response theme={null}
┌─Tuple─────────────────────────────────────────────────────────────────┐
│ (('OLAP','database','analytical'),('online','oriented','processing')) │
└───────────────────────────────────────────────────────────────────────┘
```

<h2 id="wordShingleMinHashArgCaseInsensitive">
  wordShingleMinHashArgCaseInsensitive
</h2>

Introduced in: v21.1.0

Splits a ASCII string into parts (shingles) of `shinglesize` words each and returns the shingles with minimum and maximum word hashes, calculated by the [`wordShingleMinHashCaseInsensitive`](#wordShingleMinHashCaseInsensitive) function with the same input.
It is case insensitive.

**Syntax**

```sql theme={null}
wordShingleMinHashArgCaseInsensitive(string[, shinglesize, hashnum])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `shinglesize` — Optional. The size of a word shingle, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)
* `hashnum` — Optional. The number of minimum and maximum hashes used to calculate the result, any number from `1` to `25`. The default value is `6`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns a tuple with two tuples with `hashnum` word shingles each. [`Tuple(Tuple(String))`](/reference/data-types/tuple)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT wordShingleMinHashArgCaseInsensitive('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).', 1, 3) AS Tuple;
```

```response title=Response theme={null}
┌─Tuple──────────────────────────────────────────────────────────────────┐
│ (('queries','database','analytical'),('oriented','processing','DBMS')) │
└────────────────────────────────────────────────────────────────────────┘
```

<h2 id="wordShingleMinHashArgCaseInsensitiveUTF8">
  wordShingleMinHashArgCaseInsensitiveUTF8
</h2>

Introduced in: v21.1.0

Splits a UTF-8 string into parts (shingles) of `shinglesize` words each and returns the shingles with minimum and maximum word hashes, calculated by the [`wordShingleMinHashCaseInsensitiveUTF8`](#wordShingleMinHashCaseInsensitiveUTF8) function with the same input.
It is case insensitive.

**Syntax**

```sql theme={null}
wordShingleMinHashArgCaseInsensitiveUTF8(string[, shinglesize, hashnum])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `shinglesize` — Optional. The size of a word shingle, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)
* `hashnum` — Optional. The number of minimum and maximum hashes used to calculate the result, any number from `1` to `25`. The default value is `6`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns a tuple with two tuples with `hashnum` word shingles each. [`Tuple(Tuple(String))`](/reference/data-types/tuple)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT wordShingleMinHashArgCaseInsensitiveUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).', 1, 3) AS Tuple;
```

```response title=Response theme={null}
┌─Tuple──────────────────────────────────────────────────────────────────┐
│ (('queries','database','analytical'),('oriented','processing','DBMS')) │
└────────────────────────────────────────────────────────────────────────┘
```

<h2 id="wordShingleMinHashArgUTF8">
  wordShingleMinHashArgUTF8
</h2>

Introduced in: v21.1.0

Splits a UTF-8 string into parts (shingles) of `shinglesize` words each and returns the shingles with minimum and maximum word hashes, calculated by the [`wordShingleMinHashUTF8`](#wordShingleMinHashUTF8) function with the same input.
It is case sensitive.

**Syntax**

```sql theme={null}
wordShingleMinHashArgUTF8(string[, shinglesize, hashnum])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `shinglesize` — Optional. The size of a word shingle, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)
* `hashnum` — Optional. The number of minimum and maximum hashes used to calculate the result, any number from `1` to `25`. The default value is `6`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns a tuple with two tuples with `hashnum` word shingles each. [`Tuple(Tuple(String))`](/reference/data-types/tuple)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT wordShingleMinHashArgUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).', 1, 3) AS Tuple;
```

```response title=Response theme={null}
┌─Tuple─────────────────────────────────────────────────────────────────┐
│ (('OLAP','database','analytical'),('online','oriented','processing')) │
└───────────────────────────────────────────────────────────────────────┘
```

<h2 id="wordShingleMinHashCaseInsensitive">
  wordShingleMinHashCaseInsensitive
</h2>

Introduced in: v21.1.0

Splits a ASCII string into parts (shingles) of `shinglesize` words, calculates hash values for each word shingle and returns a tuple with these hashes.
Uses `hashnum` minimum hashes to calculate the minimum hash and `hashnum` maximum hashes to calculate the maximum hash.
It is case insensitive.

Can be used to detect semi-duplicate strings with [`tupleHammingDistance`](/reference/functions/regular-functions/tuple-functions#tupleHammingDistance).
For two strings, if the returned hashes are the same for both strings, then those strings are the same.

**Syntax**

```sql theme={null}
wordShingleMinHashCaseInsensitive(string[, shinglesize, hashnum])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `shinglesize` — Optional. The size of a word shingle, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)
* `hashnum` — Optional. The number of minimum and maximum hashes used to calculate the result, any number from `1` to `25`. The default value is `6`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns a tuple with two hashes — the minimum and the maximum. [`Tuple(UInt64, UInt64)`](/reference/data-types/tuple)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT wordShingleMinHashCaseInsensitive('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Tuple;
```

```response title=Response theme={null}
┌─Tuple─────────────────────────────────────┐
│ (3065874883688416519,1634050779997673240) │
└───────────────────────────────────────────┘
```

<h2 id="wordShingleMinHashCaseInsensitiveUTF8">
  wordShingleMinHashCaseInsensitiveUTF8
</h2>

Introduced in: v21.1.0

Splits a UTF-8 string into parts (shingles) of `shinglesize` words, calculates hash values for each word shingle and returns a tuple with these hashes.
Uses `hashnum` minimum hashes to calculate the minimum hash and `hashnum` maximum hashes to calculate the maximum hash.
It is case insensitive.

Can be used to detect semi-duplicate strings with [`tupleHammingDistance`](/reference/functions/regular-functions/tuple-functions#tupleHammingDistance).
For two strings, if the returned hashes are the same for both strings, then those strings are the same.

**Syntax**

```sql theme={null}
wordShingleMinHashCaseInsensitiveUTF8(string[, shinglesize, hashnum])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `shinglesize` — Optional. The size of a word shingle, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)
* `hashnum` — Optional. The number of minimum and maximum hashes used to calculate the result, any number from `1` to `25`. The default value is `6`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns a tuple with two hashes — the minimum and the maximum. [`Tuple(UInt64, UInt64)`](/reference/data-types/tuple)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT wordShingleMinHashCaseInsensitiveUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Tuple;
```

```response title=Response theme={null}
┌─Tuple─────────────────────────────────────┐
│ (3065874883688416519,1634050779997673240) │
└───────────────────────────────────────────┘
```

<h2 id="wordShingleMinHashUTF8">
  wordShingleMinHashUTF8
</h2>

Introduced in: v21.1.0

Splits a UTF-8 string into parts (shingles) of `shinglesize` words, calculates hash values for each word shingle and returns a tuple with these hashes.
Uses `hashnum` minimum hashes to calculate the minimum hash and `hashnum` maximum hashes to calculate the maximum hash.
It is case sensitive.

Can be used to detect semi-duplicate strings with [`tupleHammingDistance`](/reference/functions/regular-functions/tuple-functions#tupleHammingDistance).
For two strings, if the returned hashes are the same for both strings, then those strings are the same.

**Syntax**

```sql theme={null}
wordShingleMinHashUTF8(string[, shinglesize, hashnum])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `shinglesize` — Optional. The size of a word shingle, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)
* `hashnum` — Optional. The number of minimum and maximum hashes used to calculate the result, any number from `1` to `25`. The default value is `6`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns a tuple with two hashes — the minimum and the maximum. [`Tuple(UInt64, UInt64)`](/reference/data-types/tuple)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT wordShingleMinHashUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Tuple;
```

```response title=Response theme={null}
┌─Tuple──────────────────────────────────────┐
│ (16452112859864147620,5844417301642981317) │
└────────────────────────────────────────────┘
```

<h2 id="wordShingleSimHash">
  wordShingleSimHash
</h2>

Introduced in: v21.1.0

Splits a ASCII string into parts (shingles) of `shinglesize` words and returns the word shingle `simhash`.
Is is case sensitive.

Can be used for detection of semi-duplicate strings with [`bitHammingDistance`](/reference/functions/regular-functions/bit-functions#bitHammingDistance).
The smaller the [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) of the calculated `simhashes` of two strings, the more likely these strings are the same.

**Syntax**

```sql theme={null}
wordShingleSimHash(string[, shinglesize])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `shinglesize` — Optional. The size of a word shingle, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns the computed hash value. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT wordShingleSimHash('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Hash;
```

```response title=Response theme={null}
┌───────Hash─┐
│ 2328277067 │
└────────────┘
```

<h2 id="wordShingleSimHashCaseInsensitive">
  wordShingleSimHashCaseInsensitive
</h2>

Introduced in: v21.1.0

Splits a ASCII string into parts (shingles) of `shinglesize` words and returns the word shingle `simhash`.
It is case insensitive.

Can be used for detection of semi-duplicate strings with [`bitHammingDistance`](/reference/functions/regular-functions/bit-functions#bitHammingDistance).
The smaller the [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) of the calculated `simhashes` of two strings, the more likely these strings are the same.

**Syntax**

```sql theme={null}
wordShingleSimHashCaseInsensitive(string[, shinglesize])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `shinglesize` — Optional. The size of a word shingle, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns the computed hash value. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT wordShingleSimHashCaseInsensitive('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Hash;
```

```response title=Response theme={null}
┌───────Hash─┐
│ 2194812424 │
└────────────┘
```

<h2 id="wordShingleSimHashCaseInsensitiveUTF8">
  wordShingleSimHashCaseInsensitiveUTF8
</h2>

Introduced in: v1.1.0

Splits a UTF-8 encoded string into parts (shingles) of `shinglesize` words and returns the word shingle `simhash`.
It is case insensitive.

Can be used for detection of semi-duplicate strings with [`bitHammingDistance`](/reference/functions/regular-functions/bit-functions#bitHammingDistance).
The smaller the [Hamming Distance](https://en.wikipedia.org/wiki/Hamming_distance) of the calculated `simhashes` of two strings, the more likely these strings are the same.

**Syntax**

```sql theme={null}
wordShingleSimHashCaseInsensitiveUTF8(string[, shinglesize])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `shinglesize` — Optional. The size of a word shingle, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns the computed hash value. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT wordShingleSimHashCaseInsensitiveUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Hash;
```

```response title=Response theme={null}
┌───────Hash─┐
│ 2194812424 │
└────────────┘
```

<h2 id="wordShingleSimHashUTF8">
  wordShingleSimHashUTF8
</h2>

Introduced in: v21.1.0

Splits a UTF-8 string into parts (shingles) of `shinglesize` words and returns the word shingle `simhash`.
It is case sensitive.

Can be used for detection of semi-duplicate strings with [`bitHammingDistance`](/reference/functions/regular-functions/bit-functions#bitHammingDistance).
The smaller the [Hamming distance](https://en.wikipedia.org/wiki/Hamming_distance) of the calculated `simhashes` of two strings, the more likely these strings are the same.

**Syntax**

```sql theme={null}
wordShingleSimHashUTF8(string[, shinglesize])
```

**Arguments**

* `string` — String for which to compute the hash. [`String`](/reference/data-types/string)
* `shinglesize` — Optional. The size of a word shingle, any number from `1` to `25`. The default value is `3`. [`UInt8`](/reference/data-types/int-uint)

**Returned value**

Returns the computed hash value. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT wordShingleSimHashUTF8('ClickHouse® is a column-oriented database management system (DBMS) for online analytical processing of queries (OLAP).') AS Hash;
```

```response title=Response theme={null}
┌───────Hash─┐
│ 2328277067 │
└────────────┘
```

<h2 id="wyHash64">
  wyHash64
</h2>

Introduced in: v22.7.0

Computes a 64-bit [wyHash64](https://github.com/wangyi-fudan/wyhash) hash value.

**Syntax**

```sql theme={null}
wyHash64(arg)
```

**Arguments**

* `arg` — String argument for which to compute the hash. [`String`](/reference/data-types/string)

**Returned value**

Returns the computed 64-bit hash value [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT wyHash64('ClickHouse') AS Hash;
```

```response title=Response theme={null}
12336419557878201794
```

<h2 id="xxHash32">
  xxHash32
</h2>

Introduced in: v20.1.0

Calculates a [xxHash](http://cyan4973.github.io/xxHash/) from a string.

For the 64-bit version see [`xxHash64`](#xxHash64)

**Syntax**

```sql theme={null}
xxHash32(arg)
```

**Arguments**

* `arg` — Input string to hash. [`String`](/reference/data-types/string)

**Returned value**

Returns the computed 32-bit hash of the input string. [`UInt32`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT xxHash32('Hello, world!');
```

```response title=Response theme={null}
┌─xxHash32('Hello, world!')─┐
│                 834093149 │
└───────────────────────────┘
```

<h2 id="xxHash64">
  xxHash64
</h2>

Introduced in: v20.1.0

Calculates a [xxHash](http://cyan4973.github.io/xxHash/) from a string.

For the 32-bit version see [`xxHash32`](#xxHash32)

**Syntax**

```sql theme={null}
xxHash64(arg)
```

**Arguments**

* `arg` — Input string to hash. [`String`](/reference/data-types/string)

**Returned value**

Returns the computed 64-bit hash of the input string. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT xxHash64('Hello, world!');
```

```response title=Response theme={null}
┌─xxHash64('Hello, world!')─┐
│      17691043854468224118 │
└───────────────────────────┘
```

<h2 id="xxh3">
  xxh3
</h2>

Introduced in: v22.12.0

Computes a [XXH3](https://github.com/Cyan4973/xxHash) 64-bit hash value.

**Syntax**

```sql theme={null}
xxh3(expr)
```

**Arguments**

* `expr` — A list of expressions of any data type. [`Any`](/reference/data-types/index)

**Returned value**

Returns the computed 64-bit `xxh3` hash value [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT xxh3('ClickHouse')
```

```response title=Response theme={null}
18009318874338624809
```

<h2 id="xxh3_128">
  xxh3\_128
</h2>

Introduced in: v26.2.0

Computes a [XXH3](https://github.com/Cyan4973/xxHash) 128-bit hash value.

**Syntax**

```sql theme={null}
xxh3_128(expr)
```

**Arguments**

* `expr` — A list of expressions of any data type. [`Any`](/reference/data-types/index)

**Returned value**

Returns the computed 128-bit `xxh3` hash value [`UInt128`](/reference/data-types/int-uint)

**Examples**

**Usage example**

```sql title=Query theme={null}
SELECT hex(xxh3_128('ClickHouse'))
```

```response title=Response theme={null}
3A038784C52804B4DBA43A038784C528
```
