token

package
v0.0.0-...-fa37cd3 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2019 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Error indicating that a token was malformed.
	ErrInvalidToken = errors.New("Invalid token.")

	// Indicating that verification failed, because the token was
	// incorrect.
	ErrIncorrectToken = errors.New("Incorrect token.")
)

Functions

This section is empty.

Types

type Token

type Token [128 / 8]byte

A cryptographically random 128-bit value.

func New

func New() (Token, error)

Generate a new, cryptographically random token.

func (Token) MarshalText

func (t Token) MarshalText() ([]byte, error)

func (*Token) UnmarshalText

func (t *Token) UnmarshalText(text []byte) error

func (Token) Verify

func (t Token) Verify(otherTok Token) error

Return an error if the tokens do not match, nil otherwise. This is constant time, and thus resistant to timing sidechannels -- DO NOT compare the tokens for equality with (==).

Jump to

Keyboard shortcuts

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