texus/utils/crpty.go
2024-12-02 14:03:35 +08:00

15 lines
275 B
Go

package utils
import (
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
)
func ComputeHmac256(message string, secret string) string {
key := []byte(secret)
h := hmac.New(sha256.New, key)
h.Write([]byte(message))
return base64.StdEncoding.EncodeToString(h.Sum(nil))
}