API Reference › Hash › Hash.fnv1a
method

Hash.fnv1a

Hash.fnv1a(s) -> int

The FNV-1a hash of a string's bytes, as an explicit 32-bit algorithm. It starts from the standard offset basis 0x811c9dc5 and, for each byte, XORs the byte in and multiplies by the FNV prime 0x01000193. Small, allocation-free, and well-distributed for short strings — ideal for map keys and content ids. This is the same function Hash.of currently delegates to; call Hash.fnv1a when you want to pin the algorithm by name so the value stays fixed even if the default changes.

Parameters

sthe string to hash

Example

program Fnv {
  entry {
    print(Hash.fnv1a(""))            # the empty string -> the offset basis
    print(Hash.fnv1a("grass_tile"))
  }
}
← All symbols