Commit 91ddc07f authored by Shenghou Ma's avatar Shenghou Ma Committed by Minux Ma

hash/*: document the byte order used by the Sum methods

Fixes #12350.

Change-Id: I3dcb0e2190c11f83f15fb07cc637fead54f734f7
Reviewed-on: https://go-review.googlesource.com/14275Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
parent bf216439
......@@ -33,6 +33,7 @@ type digest uint32
func (d *digest) Reset() { *d = 1 }
// New returns a new hash.Hash32 computing the Adler-32 checksum.
// Its Sum method will lay the value out in big-endian byte order.
func New() hash.Hash32 {
d := new(digest)
d.Reset()
......
......@@ -113,10 +113,12 @@ type digest struct {
// New creates a new hash.Hash32 computing the CRC-32 checksum
// using the polynomial represented by the Table.
// Its Sum method will lay the value out in big-endian byte order.
func New(tab *Table) hash.Hash32 { return &digest{0, tab} }
// NewIEEE creates a new hash.Hash32 computing the CRC-32 checksum
// using the IEEE polynomial.
// Its Sum method will lay the value out in big-endian byte order.
func NewIEEE() hash.Hash32 { return New(IEEETable) }
func (d *digest) Size() int { return Size }
......
......@@ -50,6 +50,7 @@ type digest struct {
// New creates a new hash.Hash64 computing the CRC-64 checksum
// using the polynomial represented by the Table.
// Its Sum method will lay the value out in big-endian byte order.
func New(tab *Table) hash.Hash64 { return &digest{0, tab} }
func (d *digest) Size() int { return Size }
......
......@@ -27,24 +27,28 @@ const (
)
// New32 returns a new 32-bit FNV-1 hash.Hash.
// Its Sum method will lay the value out in big-endian byte order.
func New32() hash.Hash32 {
var s sum32 = offset32
return &s
}
// New32a returns a new 32-bit FNV-1a hash.Hash.
// Its Sum method will lay the value out in big-endian byte order.
func New32a() hash.Hash32 {
var s sum32a = offset32
return &s
}
// New64 returns a new 64-bit FNV-1 hash.Hash.
// Its Sum method will lay the value out in big-endian byte order.
func New64() hash.Hash64 {
var s sum64 = offset64
return &s
}
// New64a returns a new 64-bit FNV-1a hash.Hash.
// Its Sum method will lay the value out in big-endian byte order.
func New64a() hash.Hash64 {
var s sum64a = offset64
return &s
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment