1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-17 16:12:42 +08:00

hmac name

This commit is contained in:
2022-06-27 14:41:21 +08:00
parent d1a4cfda24
commit dcd803b4f2

View File

@ -21,13 +21,13 @@ var _ crypto.Signer = &hashComparer{}
type HMacFunc func(key, msg []byte) bytesconv.BytesResult type HMacFunc func(key, msg []byte) bytesconv.BytesResult
var hmacFuncs = map[string]HMacFunc{ var hmacFuncs = map[string]HMacFunc{
"HmacMD5": Md5, "HMACMD5": Md5,
"HmacSHA1": Sha1, "HMACSHA1": Sha1,
"HmacSHA224": Sha224, "HMACSHA224": Sha224,
"HmacSHA256": Sha256, "HMACSHA256": Sha256,
"HmacSHA384": Sha384, "HMACSHA384": Sha384,
"HmacSHA512": Sha512, "HMACSHA512": Sha512,
"HmacSM3": Sm3, "HMACSM3": Sm3,
} }
type hashComparer struct { type hashComparer struct {
@ -63,7 +63,7 @@ func ByName(name string) (HMacFunc, error) {
return f, nil return f, nil
} }
return nil, errors.New("Unsupported hash functions") return nil, errors.New("Unsupported hash function:" + name)
} }
func Md5(key, msg []byte) bytesconv.BytesResult { return sum(md5.New, key, msg) } func Md5(key, msg []byte) bytesconv.BytesResult { return sum(md5.New, key, msg) }