package main import ( "crypto/hmac" "crypto/sha512" "fmt" ) func mac(key, msg []byte) []byte { h := hmac.New(sha512.New, key); h.Write(msg); return h.Sum(nil) } func main() { fmt.Printf("%x\n", mac([]byte("demo key"), []byte("demo message"))) }