HASH8 scalar function
The HASH8 function returns the 64-bit hash of an input string. The function provides 264 distinct return values and is intended for data retrieval (that is, lookups). The result for a particular input string differs depending on the endianness (big-endian or little-endian) of your system.
The schema is SYSIBM.
- string-expression
- An expression that represents the string value to be hashed. This expression must return a built-in character string, graphic string, binary string, numeric value, Boolean value, or datetime value. If the value is not a character, graphic, or binary string, it is implicitly cast to VARCHAR before the function is evaluated.
- algorithm
- An expression that returns a value that indicates which algorithm is to be used for hashing. The expression must return a value that has a built-in numeric, a CHAR, or a VARCHAR data type. In a Unicode database, the expression can also return a GRAPHIC or VARGRAPHIC data type. If the value is not an INTEGER, it is cast to INTEGER before the function is evaluated. The returned value must be 0, which indicates the Jenkins algorithm.
Result
The data type of the result is BIGINT. If the first argument can be null, the result can be null. If the first argument is null, the result is the null value.
Example
values hash8('Charlie at IBM', 0)
- On a little-endian system, the result is 4570902652830829618.
- On a big-endian system, the result is 7187665777530874019.