bitbucket.org/ai69/amoy@v0.2.3/hash.go (about) 1 package amoy 2 3 import ( 4 "hash/fnv" 5 ) 6 7 // FNV32a returns the 32-bit FNV-1a hash of the given string. 8 func FNV32a(text string) uint32 { 9 algorithm := fnv.New32a() 10 _, _ = algorithm.Write([]byte(text)) 11 return algorithm.Sum32() 12 } 13 14 // FNV64a returns the 64-bit FNV-1a hash of the given string. 15 func FNV64a(text string) uint64 { 16 algorithm := fnv.New64a() 17 _, _ = algorithm.Write([]byte(text)) 18 return algorithm.Sum64() 19 } 20 21 // FNV128a returns the 128-bit FNV-1a hash of the given string. 22 func FNV128a(text string) []byte { 23 algorithm := fnv.New128a() 24 _, _ = algorithm.Write([]byte(text)) 25 return algorithm.Sum(nil) 26 }