Documentation
¶
Index ¶
Constants ¶
const ( // Lengths of hash outputs in bytes HashLenSHA2_256 = 32 HashLenSHA2_384 = 48 HashLenSHA3_256 = 32 HashLenSHA3_384 = 48 HashLenKeccak_256 = 32 // KMAC // the minimum key length in bytes KmacMinKeyLen = securityBits / 8 )
Variables ¶
This section is empty.
Functions ¶
func ComputeSHA2_256 ¶
func ComputeSHA2_256(result *[HashLenSHA2_256]byte, data []byte)
ComputeSHA2_256 computes the SHA2-256 (commonly known as SHA256) digest of data and copies the result to the result buffer.
The function is not part of the Hasher API. It is a pure function for simple computation of a hash with minimal heap allocations.
func ComputeSHA3_256 ¶
func ComputeSHA3_256(result *[HashLenSHA3_256]byte, data []byte)
ComputeSHA3_256 computes the SHA3-256 digest of data and copies the result to the result buffer.
The function is not part of the Hasher API. It is a pure function for simple computation of a hash with minimal heap allocations.
Types ¶
type Hash ¶
type Hash []byte
Hash is the hash algorithms output types
type Hasher ¶
type Hasher interface { // Algorithm returns the hashing algorithm of the hasher. Algorithm() HashingAlgorithm // Size returns the hash output length in bytes. Size() int // ComputeHash returns the hash output regardless of the existing hash state. // It may update the state or not depending on the implementation. Thread safety // also depends on the implementation. ComputeHash([]byte) Hash // Write([]bytes) (using the io.Writer interface) adds more bytes to the // current hash state. io.Writer // SumHash returns the hash output. // It may update the state or not depending on the implementation. SumHash() Hash // Reset resets the hash state. Reset() }
Hasher interface
func NewKMAC_128 ¶
NewKMAC_128 returns a new KMAC instance
- key is the KMAC key (the key size is compared to the security level, although the parameter is used as a domain tag in Flow and not as a security key).
- customizer is the customization string. It can be left empty if no customizer is required.
func NewKeccak_256 ¶
func NewKeccak_256() Hasher
NewKeccak_256 returns a new instance of legacy Keccak-256 hasher.
type HashingAlgorithm ¶
type HashingAlgorithm int
HashingAlgorithm is an identifier for a hashing algorithm.
const ( // Supported hashing algorithms UnknownHashingAlgorithm HashingAlgorithm = iota // SHA-2 SHA2_256 SHA2_384 // SHA-3 SHA3_256 SHA3_384 // KMAC (Keccak based MAC algorithm) KMAC128 // legacy Keccak Keccak_256 )
func (HashingAlgorithm) String ¶
func (h HashingAlgorithm) String() string
String returns the string representation of this hashing algorithm.