18 lines
316 B
Go
18 lines
316 B
Go
package requests
|
|
|
|
import (
|
|
"crypto/hmac"
|
|
"crypto/sha256"
|
|
"encoding/hex"
|
|
)
|
|
|
|
func HmacSha256(secret string, message string) string {
|
|
if len(secret) == 0 || len(message) == 0 {
|
|
return ""
|
|
}
|
|
|
|
key := []byte(secret)
|
|
h := hmac.New(sha256.New, key)
|
|
h.Write([]byte(message))
|
|
return hex.EncodeToString(h.Sum(nil))
|
|
}
|