hmac
packagestandard libraryThis 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 hmac implements the Keyed-Hash Message Authentication Code (HMAC) asdefined in U.S. Federal Information Processing Standards Publication 198.An HMAC is a cryptographic hash that uses a key to sign a message.The receiver verifies the hash by recomputing it using the same key.
Receivers should be careful to use Equal to compare MACs in order to avoidtiming side-channels:
// ValidMAC reports whether messageMAC is a valid HMAC tag for message.func ValidMAC(message, messageMAC, key []byte) bool {mac := hmac.New(sha256.New, key)mac.Write(message)expectedMAC := mac.Sum(nil)return hmac.Equal(messageMAC, expectedMAC)}Index¶
Constants¶
This section is empty.
Variables¶
This section is empty.
Functions¶
funcNew¶
New returns a new HMAC hash using the givenhash.Hash type and key.New functions likecrypto/sha256.New can be used as h.h must return a new Hash every time it is called.Note that unlike other hash implementations in the standard library,the returned Hash does not implementencoding.BinaryMarshalerorencoding.BinaryUnmarshaler.
Types¶
This section is empty.