func (s *HmacSigner) Decode(buf []byte, obj interface{}) error {
	return s.alg.Decode(s, buf, obj)
}
Decode decodes a serialized token, verifying the signature, storing the
decoded data from the token in obj.
package jwt
import (
	"crypto"
	"crypto/hmac"
)
type HmacSigner struct {
	alg  Algorithm
	hash crypto.Hash
	key  []byte
}
func NewHMACSigner(alg Algorithm) func(Store, crypto.Hash) (Signer, error) {
	return func(store Store, hash crypto.Hash) (Signer, error) {
		var ok bool
		var keyRaw interface{}
		var key []byte
		if keyRaw, ok = store.PrivateKey(); !ok {
			return nil, ErrMissingPrivateKey
		}
		if key, ok = keyRaw.([]byte); !ok {
			return nil, ErrInvalidPrivateKey
		}
		return &HmacSigner{
			alg:  alg,
			hash: hash,
			key:  key,
		}, nil
	}
}
func (s *HmacSigner) SignBytes(buf []byte) ([]byte, error) {
	if s.key == nil {
		return nil, ErrMissingPrivateKey
	}
	h := hmac.New(s.hash.New, s.key)
	if _, err := h.Write(buf); err != nil {
		return nil, err
	}
	return h.Sum(nil), nil
}
func (s *HmacSigner) Sign(buf []byte) ([]byte, error) {
	sig, err := s.SignBytes(buf)
	if err != nil {
		return nil, err
	}
	enc := make([]byte, b64.EncodedLen(len(sig)))
	b64.Encode(enc, sig)
	return enc, nil
}
func (s *HmacSigner) VerifyBytes(buf, sig []byte) error {
	if s.key == nil {
		return ErrMissingPrivateKey
	}
	h := hmac.New(s.hash.New, s.key)
	if _, err := h.Write(buf); err != nil {
		return err
	}
	if !hmac.Equal(h.Sum(nil), sig) {
		return ErrInvalidSignature
	}
	return nil
}
func (s *HmacSigner) Verify(buf, sig []byte) ([]byte, error) {
	dec, err := b64.DecodeString(string(sig))
	if err != nil {
		return nil, err
	}
	if err = s.VerifyBytes(buf, dec); err != nil {
		return nil, err
	}
	return dec, nil
}
func (s *HmacSigner) Encode(obj interface{}) ([]byte, error) {
	return s.alg.Encode(s, obj)
}