UNPKG

@anglinb/city-hash

Version:

TypeScript implementation of CityHash64 - fast, non-cryptographic hash function

25 lines (24 loc) 745 B
/** * CityHash64 - Fast, non-cryptographic hash function * * Computes a 64-bit hash of the input data using Google's CityHash algorithm. * This is a fast, high-quality hash function suitable for hash tables and * other non-cryptographic uses. * * @param input - The data to hash (string or Uint8Array) * @returns A 64-bit hash value as a BigInt * * @example * ```typescript * import { cityHash64 } from '@anglinb/city-hash'; * * // Hash a string * const hash1 = cityHash64("hello world"); * console.log(hash1); // 12386028635079221413n * * // Hash binary data * const data = new Uint8Array([1, 2, 3, 4, 5]); * const hash2 = cityHash64(data); * ``` */ export declare function cityHash64(input: string | Uint8Array): bigint;