• Hashes a string into a 53-bit integer.

    A fast and simple 53-bit string hash function with decent collision resistance.

    Parameters

    • str: string

      The string to hash.

    • seed: number = 0

      An optional seed value to initialize the hash.

    Returns number

    A 53-bit integer hash of the input string.

    This is a non-cryptographic hash function, suitable for hash tables and similar applications. It is not suitable for cryptographic purposes.

    cyrb53 (c) 2018 bryc (github.com/bryc) License: Public domain (or MIT if needed). Attribution appreciated. Largely inspired by MurmurHash2/3, but with a focus on speed/simplicity. https://github.com/bryc/code/blob/master/jshash/experimental/cyrb53.js

    const hash = cyrb53("Hello, world!");
    console.log(hash); // 1234567890123456789
    const hashWithSeed = cyrb53("Hello, world!", 42);
    console.log(hashWithSeed); // 9876543210987654321