Standard library / hash/fnv

hash/fnv.New128a()

Create a 128-bit FNV-1a streaming hash. XOR each input byte then multiply modulo 2^128. 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: 'e3e1efd54283d94f7081314b599d31b3\n'.

Formal Syntax & Structure

go syntaxgo
func New128a() hash.Hash

Return Value

hash.Hash

Fresh incremental hash.

Working Example

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