secmsg

package
v0.10.3-rc2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2020 License: GPL-3.0 Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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