Documentation ¶
Overview ¶
Package cityhash provides hash functions for strings. The functions mix the input bits thoroughly but are not suitable for cryptography. See "Hash Quality," below, for details on how CityHash was tested and so on.
All members of the CityHash family were designed with heavy reliance on previous work by Austin Appleby, Bob Jenkins, and others. For example, CityHash32 has many similarities with Murmur3a.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CityHash32 ¶
CityHash32 return 32-bit hash.
Example ¶
s := []byte("hello") hash32 := CityHash32(s) fmt.Printf("the 32-bit hash of 'hello' is: 0x%x\n", hash32)
Output: the 32-bit hash of 'hello' is: 0x79969366
func CityHash64 ¶
CityHash64 return a 64-bit hash.
Example ¶
s := []byte("hello") hash64 := CityHash64(s) fmt.Printf("the 64-bit hash of 'hello' is: 0x%x\n", hash64)
Output: the 64-bit hash of 'hello' is: 0xb48be5a931380ce8
func CityHash64WithSeed ¶
CityHash64WithSeed return a 64-bit hash with a seed.
func CityHash64WithSeeds ¶
CityHash64WithSeeds return a 64-bit hash with two seeds.
Types ¶
type Uint128 ¶
type Uint128 [2]uint64
Uint128 type uint128
func CityHash128 ¶
CityHash128 return a 128-bit hash and are tuned for strings of at least a few hundred bytes. Depending on your compiler and hardware, it's likely faster than CityHash64() on sufficiently long strings. It's slower than necessary on shorter strings, but we expect that case to be relatively unimportant.
Example ¶
s := []byte("hello") hash128 := CityHash128(s) fmt.Printf("the 128-bit hash of 'hello' is: 0x%x%x\n", hash128.High64(), hash128.Low64())
Output: the 128-bit hash of 'hello' is: 0x65148f580b45f3476f72e4abb491a74a
func CityHash128WithSeed ¶
CityHash128WithSeed return a 128-bit hash with a seed.