Standard library / hash
hash.Hash
Common incremental hash interface. Write accepts input; Sum appends the digest without consuming state; Reset clears input; Size gives digest length and BlockSize gives preferred input granularity. Implementations need not be concurrency-safe. Some support binary state serialization; state may expose input bytes. This is not a cryptographic authentication primitive. Expected stdout: '4f9f2cab 4\n'.
Formal Syntax & Structure
go syntaxgo
type Hash interface { io.Writer
Sum(b []byte) []byte
Reset()
Size() int
BlockSize() int}Working Example
Example Snippetgo
package main
import ( "fmt" "hash" "hash/fnv")
func main() { var h hash.Hash = fnv.New32a() h.Write([]byte("hello")) fmt.Printf("%x %d\n", h.Sum(nil), h.Size())}