Standard library / hash/fnv

hash/fnv.New64()

Create a 64-bit FNV-1 streaming hash. Multiply then XOR each input byte modulo 2^64. Sum returns big-endian digest bytes. Useful for deterministic non-adversarial hashing; collisions are possible. Supports binary state marshaling. This is not a cryptographic authentication primitive. Expected stdout: '7b495389bdbdd4c7\n'.

Formal Syntax & Structure

go syntaxgo
func New64() hash.Hash64

Return Value

hash.Hash64

Fresh incremental 64-bit hash.

Working Example

Example Snippetgo
package main
import (  "fmt"  "hash/fnv")
func main() {  h := fnv.New64()  h.Write([]byte("he"))  h.Write([]byte("llo"))  fmt.Printf("%x\n", h.Sum(nil))}
Go Reference