API Reference › Hash › Hash.fnv1a_64
method

Hash.fnv1a_64

Hash.fnv1a_64(s) -> long

The 64-bit FNV-1a hash of a string's bytes, returned as a long. It uses the standard 64-bit offset basis 0xcbf29ce484222325 and prime 0x100000001b3: for each byte, XOR it in and multiply by the prime. Its wider output makes accidental collisions vanishingly unlikely for the id and registry use cases games hit. This is the function Hash.of64 delegates to; call Hash.fnv1a_64 when you want the algorithm pinned by name.

Parameters

sthe string to hash

Example

program Fnv64 {
  entry {
    print(Hash.fnv1a_64(""))            # the empty string -> the 64-bit offset basis
    print(Hash.fnv1a_64("grass_tile"))
  }
}
← All symbols