Source file src/pkg/hash/hash.go
1 // Copyright 2009 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // Package hash provides interfaces for hash functions. 6 package hash 7 8 import "io" 9 10 // Hash is the common interface implemented by all hash functions. 11 type Hash interface { 12 // Write adds more data to the running hash. 13 // It never returns an error. 14 io.Writer 15 16 // Sum returns the current hash, without changing the 17 // underlying hash state. 18 Sum() []byte 19 20 // Reset resets the hash to one with zero bytes written. 21 Reset() 22 23 // Size returns the number of bytes Sum will return. 24 Size() int 25 } 26 27 // Hash32 is the common interface implemented by all 32-bit hash functions. 28 type Hash32 interface { 29 Hash 30 Sum32() uint32 31 } 32 33 // Hash64 is the common interface implemented by all 64-bit hash functions. 34 type Hash64 interface { 35 Hash 36 Sum64() uint64 37 }