Skip to content

Instantly share code, notes, and snippets.

@tejzpr
Created March 1, 2021 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tejzpr/bb2cfe54f4f28a2003f09658362d6dd4 to your computer and use it in GitHub Desktop.
Save tejzpr/bb2cfe54f4f28a2003f09658362d6dd4 to your computer and use it in GitHub Desktop.
FNV Hash - Go
package main
import "fmt"
func fnvHash32(key string) uint32 {
hash := uint32(2156825496)
const prime32 = uint32(16777619)
for i := 0; i < len(key); i++ {
hash *= prime32
hash ^= uint32(key[i])
}
return hash
}
func main() {
fmt.Println(fnvHash32("Hello World!"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment