func (m *SigningMethodHMAC) Verify(raw []byte, signature Signature, key interface{}) error {
	keyBytes, ok := key.([]byte)
	if !ok {
		return ErrInvalidKey
	}
	hasher := hmac.New(m.Hash.New, keyBytes)
	hasher.Write(raw)
	if hmac.Equal(signature, hasher.Sum(nil)) {
		return nil
	}
	return ErrSignatureInvalid
}
Verify implements the Verify method from SigningMethod.
For this signing method, must be a []byte.
package crypto
import (
	"crypto"
	"crypto/hmac"
	"encoding/json"
	"errors"
)
type SigningMethodHMAC struct {
	Name string
	Hash crypto.Hash
	_    struct{}
}
var (
	SigningMethodHS256 = &SigningMethodHMAC{
		Name: "HS256",
		Hash: crypto.SHA256,
	}
	SigningMethodHS384 = &SigningMethodHMAC{
		Name: "HS384",
		Hash: crypto.SHA384,
	}
	SigningMethodHS512 = &SigningMethodHMAC{
		Name: "HS512",
		Hash: crypto.SHA512,
	}
	ErrSignatureInvalid = errors.New("signature is invalid")
)
func (m *SigningMethodHMAC) Alg() string { return m.Name }