package lib import ( "crypto/sha256" "encoding/hex" "strings" ) // hashes an input into SHA256. func HashSHA256(input []byte) string { hasher := sha256.New() hasher.Write(input) return hex.EncodeToString(hasher.Sum(nil)) } // validates whether an input produces a hash or not. func ValidateSHA256(input []byte, hash string) bool { return strings.EqualFold(HashSHA256(input), hash) }