1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-09 15:12:26 +08:00

feat: add HmacMd5WithBase64

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

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 {