feat: add HmacMd5WithBase64

This commit is contained in:
dudaodong committed 2023-07-28 17:53:46 +08:00
1 parent 0ae5d17a06
commit 31eb5f4d1f
5 files changed
+97 -4

No files matched your search

+8
View File
@@ -104,6 +104,14 @@ func HmacMd5(str, key string) string {
return hex.EncodeToString(h.Sum([]byte("")))
}
// HmacMd5WithBase64 return the hmac hash of string use md5 with base64.
// todo
func HmacMd5WithBase64(data, key string) string {
h := hmac.New(md5.New, []byte(key))
h.Write([]byte(data))
return base64.StdEncoding.EncodeToString(h.Sum([]byte("")))
}
// HmacSha1 return the hmac hash of string use sha1.
// Play: https://go.dev/play/p/1UI4oQ4WXKM
func HmacSha1(str, key string) string {