hashx
packageThis package is not in the latest version of its module.
Details
Validgo.mod file
The Go module system was introduced in Go 1.11 and is the official dependency management solution for Go.
Redistributable license
Redistributable licenses place minimal restrictions on how software can be used, modified, and redistributed.
Tagged version
Modules with tagged versions give importers more predictable builds.
Stable version
When a project reaches major version v1 it is considered stable.
- Learn more about best practices
Repository
Links
Documentation¶
Overview¶
Package hashx provides a concrete implementation ofhash.Hashthat operates on a particular block size.
Index¶
- type Block512
- func (h *Block512) HashBytes(b []byte)
- func (h *Block512) HashString(s string)
- func (h *Block512) HashUint16(n uint16)
- func (h *Block512) HashUint32(n uint32)
- func (h *Block512) HashUint64(n uint64)
- func (h *Block512) HashUint8(n uint8)
- func (h *Block512) Reset()
- func (h *Block512) Sum(b []byte) []byte
- func (h *Block512) Write(b []byte) (int, error)
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
This section is empty.
Types¶
typeBlock512¶
Block512 wraps ahash.Hash for functions that operate on 512-bit block sizes.It has efficient methods for hashing fixed-width integers.
A hashing algorithm that operates on 512-bit block sizes should be used.The hash still operates correctly even with misaligned block sizes,but operates less efficiently.
Example algorithms with 512-bit block sizes include:
- MD4 (https://golang.org/x/crypto/md4)
- MD5 (https://golang.org/pkg/crypto/md5)
- BLAKE2s (https://golang.org/x/crypto/blake2s)
- BLAKE3
- RIPEMD (https://golang.org/x/crypto/ripemd160)
- SHA-0
- SHA-1 (https://golang.org/pkg/crypto/sha1)
- SHA-2 (https://golang.org/pkg/crypto/sha256)
- Whirlpool
Seehttps://en.wikipedia.org/wiki/Comparison_of_cryptographic_hash_functions#Parametersfor a list of hash functions and their block sizes.
Block512 assumes thathash.Hash.Write never fails andnever allows the provided buffer to escape.
funcNew512¶
New512 constructs a new Block512 that wraps h.
It reports an error if the block sizes do not match.Misaligned block sizes perform poorly, but execute correctly.The error may be ignored if performance is not a concern.
func (*Block512)HashBytes¶
HashBytes hashes the contents of b.It does not explicitly hash the length separately.
func (*Block512)HashString¶
HashString hashes the contents of s.It does not explicitly hash the length separately.
func (*Block512)HashUint16¶
HashUint16 hashes n as a 2-byte little-endian integer.
func (*Block512)HashUint32¶
HashUint32 hashes n as a 4-byte little-endian integer.
func (*Block512)HashUint64¶
HashUint64 hashes n as a 8-byte little-endian integer.
func (*Block512)Reset¶
func (h *Block512) Reset()
Reset resets Block512 to its initial state.It recursively resets the underlyinghash.Hash.
func (*Block512)Sum¶
Sum appends the current hash to b and returns the resulting slice.
It flushes any partially completed blocks to the underlyinghash.Hash,which may cause future operations to be misaligned and less efficientuntilBlock512.Reset is called.