You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
529 B
Go

package blake2
import (
// Standard
"crypto/subtle"
// Standard Extended
"golang.org/x/crypto/blake2b"
)
// Check Hash
func (algorithm Algorithm) CheckHash(data []byte, hashToCheck []byte) (bool, error) {
// Hasher
hasher, err := blake2b.New(algorithm.size, nil)
// Handle Error
if err != nil {
return false, err
}
// Write To Hasher
_, err = hasher.Write(data)
// Handle Error
if err != nil {
return false, err
}
// Return Match
return subtle.ConstantTimeCompare(hasher.Sum(nil), hashToCheck) == 1, err
}