Documentation
¶
Overview ¶
Package hash is a small wrapper around built-in cryptographic hash functions to make their usage easier.
Index ¶
Constants ¶
View Source
const ( SHA224 = Hashing(crypto.SHA224) //nolint:revive // because of compatibility with crypto library SHA256 = Hashing(crypto.SHA256) //nolint:revive // because of compatibility with crypto library SHA384 = Hashing(crypto.SHA384) //nolint:revive // because of compatibility with crypto library SHA512 = Hashing(crypto.SHA512) //nolint:revive // because of compatibility with crypto library SHA3_224 = Hashing(crypto.SHA3_224) //nolint:revive,stylecheck // because of compatibility with crypto library SHA3_256 = Hashing(crypto.SHA3_256) //nolint:revive,stylecheck // because of compatibility with crypto library SHA3_384 = Hashing(crypto.SHA3_384) //nolint:revive,stylecheck // because of compatibility with crypto library SHA3_512 = Hashing(crypto.SHA3_512) //nolint:revive,stylecheck // because of compatibility with crypto library SHA512_224 = Hashing(crypto.SHA512_224) //nolint:revive,stylecheck // because of compatibility with crypto library SHA512_256 = Hashing(crypto.SHA512_256) //nolint:revive,stylecheck // because of compatibility with crypto library BLAKE2s_256 = Hashing(crypto.BLAKE2s_256) //nolint:revive,stylecheck // because of compatibility with crypto library BLAKE2b_256 = Hashing(crypto.BLAKE2b_256) //nolint:revive,stylecheck // because of compatibility with crypto library BLAKE2b_384 = Hashing(crypto.BLAKE2b_384) //nolint:revive,stylecheck // because of compatibility with crypto library BLAKE2b_512 = Hashing(crypto.BLAKE2b_512) //nolint:revive,stylecheck // because of compatibility with crypto library )
Variables ¶
View Source
var ( // ErrMismatchLengthWrite returns when hash's write operation writes wrong length of data ErrMismatchLengthWrite = errors.New("hash: mismatch requested data and written data lengths") )
Functions ¶
This section is empty.
Types ¶
type Hash ¶
type Hash interface {
// Write (via the embedded io.Writer interface) adds more data to the running hash.
// It never returns an error.
io.Writer
// Sum appends the current hash to b and returns the resulting slice.
// It does not change the underlying hash state.
Sum(b []byte) []byte
// Reset resets the Hash to its initial state.
Reset()
// OutputSize returns the number of bytes Sum will return.
OutputSize() int
// BlockSize returns the hash's underlying block size.
// The Write method must be able to accept any amount
// of data, but it may operate more efficiently if all writes
// are a multiple of the block size.
BlockSize() int
// MustWriteAll writes all inputs into the hash's state.
MustWriteAll(inputs ...[]byte) error
// MustReadFull reads exactly len(buf) bytes from hash's state.
// It does not change the underlying hash state.
MustReadFull(buff []byte) error
// String returns string representation of the hash algorithm.
String() string
// Hmac wraps the built-in hmac.
Hmac(message, key []byte) ([]byte, error)
// HKDFExtract is an "extract" only HKDF, where the secret and salt are used to generate a pseudorandom key. This key
// can then be used in multiple HKDFExpand calls to derive individual different keys.
HKDFExtract(secret, salt []byte) []byte
// HKDFExpand is an "expand" only HKDF, where the key should be an already random/hashed input,
// and info specific key usage identifying information.
HKDFExpand(pseudorandomKey, info []byte, length int) []byte
}
Hash interface wraps standart library's hash.Hash interface with additional functions to make usage easier.
Click to show internal directories.
Click to hide internal directories.