Skip to main content

Hash Functions

Hash Functions in SQL.

FunctionDescriptionExampleResult
BLAKE3(expr)Calculates an BLAKE3 256-bit checksum for the string. The value is returned as a string of 64 hexadecimal digits or NULL if the argument was NULL.BLAKE3('1234567890')d12e417e04494572b561ba2c12c3d7f9e5107c4747e27b9a8a54f8480c63e841
CITY64WITHSEED(expr1, expr2)Calculates a City64WithSeed 64-bit hash for the string.CITY64WITHSEED('1234567890', 12)10660895976650300430
MD5(expr)Calculates an MD5 128-bit checksum for the string. The value is returned as a string of 32 hexadecimal digits or NULL if the argument was NULL.MD5('1234567890')e807f1fcf82d132f9bb018ca6738a19f
SHA(expr)Calculates an SHA-1 160-bit checksum for the string, as described in RFC 3174 (Secure Hash Algorithm). The value is returned as a string of 40 hexadecimal digits or NULL if the argument was NULL.SHA('1234567890')01b307acba4f54f55aafc33bb06bbbf6ca803e9a
SHA1(expr)Alias for SHA. Calculates an SHA-1 160-bit checksum for the string, as described in RFC 3174 (Secure Hash Algorithm). The value is returned as a string of 40 hexadecimal digits or NULL if the argument was NULL.SHA1('1234567890')01b307acba4f54f55aafc33bb06bbbf6ca803e9a
SHA2(expr, expr)Calculates the SHA-2 family of hash functions (SHA-224, SHA-256, SHA-384, and SHA-512). If the hash length is not one of the permitted values, the return value is NULL. Otherwise, the function result is a hash value containing the desired number of bits as a string of hexadecimal digits.SHA2('1234567890', 0)c775e7b757ede630cd0aa1113bd102661ab38829ca52a6422ab782862f268646
SIPHASH(expr)Produces a 64-bit SipHash hash value.SIPHASH('1234567890')18110648197875983073
SIPHASH64(expr)Alias for SIPHASH. Produces a 64-bit SipHash hash value.SIPHASH64('1234567890')18110648197875983073
XXHASH32(expr)Calculates an xxHash32 32-bit hash value for the string. The value is returned as a UInt32 or NULL if the argument was NULL.XXHASH32('1234567890')3896585587
XXHASH64(expr)Calculates an xxHash64 64-bit hash value for the string. The value is returned as a UInt64 or NULL if the argument was NULL.XXHASH64('1234567890')12237639266330420150