fnv1a32

fun fnv1a32(bytes: ByteArray): Int

Computes the 32-bit FNV-1a hash of the given bytes.

The algorithm starts from the offset basis 0x811C9DC5 and, for every byte, applies xor first and then multiplication by the prime 16777619, with all arithmetic wrapping modulo 2 to the power of 32. An empty array hashes to the offset basis itself. The result is the raw 32-bit pattern in an Int and may be negative. This function never throws.

FNV-1a is a non-cryptographic hash intended for hash tables and fast fingerprinting. It must not be used for security purposes.

Return

the 32-bit FNV-1a hash.

Parameters

bytes

the input to hash.


Computes the 32-bit FNV-1a hash of this string encoded as UTF-8.

The string is first converted to its UTF-8 bytes and then hashed with fnv1a32, so all documentation of that function applies. An empty string hashes to the offset basis 0x811C9DC5. This function never throws.

Return

the 32-bit FNV-1a hash.