evcc-io/vehicle/saic/requests/macUtils.go
2024-02-28 21:30:40 +01:00

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))
}