feat: add geetest captcha (#953)

This commit is contained in:
Resulte Lee
2022-08-04 20:55:04 +08:00
committed by GitHub
parent d55ae7d1d2
commit 4ea482223d
5 changed files with 130 additions and 3 deletions

View File

@ -17,7 +17,9 @@ package util
import (
"crypto/hmac"
"crypto/sha1"
"crypto/sha256"
"encoding/base64"
"encoding/hex"
)
func GetHmacSha1(keyStr, value string) string {
@ -28,3 +30,10 @@ func GetHmacSha1(keyStr, value string) string {
return res
}
func GetHmacSha256(key string, data string) string {
mac := hmac.New(sha256.New, []byte(key))
mac.Write([]byte(data))
return hex.EncodeToString(mac.Sum(nil))
}