github.com/razvanm/vanadium-go-1.3@v0.0.0-20160721203343-4a65068e5915/src/hash/hash.go (about)

     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 (via the embedded io.Writer interface) adds more data to the running hash.
    13  	// It never returns an error.
    14  	io.Writer
    15  
    16  	// Sum appends the current hash to b and returns the resulting slice.
    17  	// It does not change the underlying hash state.
    18  	Sum(b []byte) []byte
    19  
    20  	// Reset resets the Hash to its initial state.
    21  	Reset()
    22  
    23  	// Size returns the number of bytes Sum will return.
    24  	Size() int
    25  
    26  	// BlockSize returns the hash's underlying block size.
    27  	// The Write method must be able to accept any amount
    28  	// of data, but it may operate more efficiently if all writes
    29  	// are a multiple of the block size.
    30  	BlockSize() int
    31  }
    32  
    33  // Hash32 is the common interface implemented by all 32-bit hash functions.
    34  type Hash32 interface {
    35  	Hash
    36  	Sum32() uint32
    37  }
    38  
    39  // Hash64 is the common interface implemented by all 64-bit hash functions.
    40  type Hash64 interface {
    41  	Hash
    42  	Sum64() uint64
    43  }