From fdd5b0799213879cbc6313ee3bdded2f97795150 Mon Sep 17 00:00:00 2001 From: tiglog Date: Sat, 12 Aug 2023 21:29:17 +0800 Subject: [PATCH] feat: add HmacSha1 --- crypto/gsha1/sha1.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crypto/gsha1/sha1.go b/crypto/gsha1/sha1.go index 3622fdc..b237e6f 100644 --- a/crypto/gsha1/sha1.go +++ b/crypto/gsha1/sha1.go @@ -8,6 +8,7 @@ package gsha1 import ( + "crypto/hmac" "crypto/sha1" "encoding/hex" "io" @@ -45,3 +46,10 @@ func MustEncryptFile(path string) string { } return result } + +// hmac sha1 +func HmacSha1(in, key []byte) []byte { + h := hmac.New(sha1.New, key) + h.Write(in) + return h.Sum(nil) +}