package main import ( "fmt" "encoding/hex" "encoding/base64" "crypto/hmac" "crypto/sha256" ) func main() { x := makeHmac("abcdef","1234567890") fmt.Printf("%s\n", x) } func makeHmac(data string, key string) string { byteKey, _ := hex.DecodeString(key) byteData := []byte(data) sig := hmac.New(sha256.New, byteKey) sig.Write([]byte(byteData)) return base64.StdEncoding.EncodeToString(sig.Sum(nil)) }