secmsg

package
v0.10.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 28, 2020 License: GPL-3.0 Imports: 3 Imported by: 0

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) Decode

func (svc *MessageService) Decode(token []byte, maxage time.Duration) ([]byte, error)

Verify verifies and decodes a token, returning an error on failure.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL