Documentation
¶
Overview ¶
Package hash implements the digest and digest_xof function families (Families 1 and 2). Supports SHA-256/384/512, SHA3-256/384/512, SHAKE128/256.
Index ¶
- func ConstantTimeCompare(a, b []byte) bool
- func Digest(data []byte, algorithm string) ([]byte, error)
- func DigestOutputLength(algo DigestAlgorithm) (int, error)
- func DigestXOF(data []byte, algorithm string, outputLength uint32) ([]byte, error)
- func ListSupportedDigests() []string
- type DigestAlgorithm
- type DigestAlgorithmInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ConstantTimeCompare ¶
ConstantTimeCompare compares two byte slices in constant time.
func Digest ¶
Digest computes the hash digest of data using the specified algorithm. Family 1: digest(data []byte, algorithm string) ([]byte, error)
func DigestOutputLength ¶
func DigestOutputLength(algo DigestAlgorithm) (int, error)
DigestOutputLength returns the output length in bytes for a fixed-output algorithm.
func DigestXOF ¶
DigestXOF computes the extendable-output hash (SHAKE) of data with variable output length. Family 2: digest_xof(data []byte, algorithm string, output_length uint32) ([]byte, error)
func ListSupportedDigests ¶
func ListSupportedDigests() []string
ListSupportedDigests returns all supported digest algorithms.
Types ¶
type DigestAlgorithm ¶
type DigestAlgorithm string
DigestAlgorithm represents a hash algorithm identifier.
const ( AlgorithmSHA256 DigestAlgorithm = "SHA-256" AlgorithmSHA384 DigestAlgorithm = "SHA-384" AlgorithmSHA512 DigestAlgorithm = "SHA-512" AlgorithmSHA3_256 DigestAlgorithm = "SHA3-256" AlgorithmSHA3_384 DigestAlgorithm = "SHA3-384" AlgorithmSHA3_512 DigestAlgorithm = "SHA3-512" AlgorithmSHAKE128 DigestAlgorithm = "SHAKE128" AlgorithmSHAKE256 DigestAlgorithm = "SHAKE256" )
type DigestAlgorithmInfo ¶
DigestAlgorithmInfo holds metadata about a digest algorithm.
func GetDigestAlgorithmInfo ¶
func GetDigestAlgorithmInfo(algorithm string) (*DigestAlgorithmInfo, error)
GetDigestAlgorithmInfo returns metadata for the given algorithm.