Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrSecretKeyLength = errors.New("secret key too short") ErrVerificationFailed = errors.New("message verification failed") )
Functions ¶
This section is empty.
Types ¶
type MessageService ¶
type MessageService struct {
// contains filtered or unexported fields
}
func NewMessageService ¶
func NewMessageService(secret []byte) (*MessageService, error)
NewMessageService sets up a message service with the given key.
func (*MessageService) Encode ¶
func (svc *MessageService) Encode(msg []byte) ([]byte, error)
Encode encodes a message, returning an error on failure.
func (*MessageService) MustDecode ¶
func (svc *MessageService) MustDecode(token []byte, maxage time.Duration) []byte
Decode verifies and decodes a token, returning an empty slice on failure.
func (*MessageService) MustEncode ¶
func (svc *MessageService) MustEncode(msg []byte) []byte
MustEncode encodes a message, calling panic on failure.
Click to show internal directories.
Click to hide internal directories.