Documentation ¶
Overview ¶
Package token implements tokens of arbitrary length that can be encoded to and from binary, text, and SQL database values. Generated text is safe for use in URLs.
Index ¶
- type Token
- func (t Token) MarshalBinary() ([]byte, error)
- func (t Token) MarshalText() (text []byte, err error)
- func (t *Token) Scan(src interface{}) error
- func (t Token) String() string
- func (t *Token) UnmarshalBinary(data []byte) error
- func (t *Token) UnmarshalText(text []byte) error
- func (t Token) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Token ¶
type Token []byte
Token is a slice of bytes.
func New ¶
NewToken returns a cryptographically secure pseudorandom Token of the given length (in bytes).
func (Token) MarshalBinary ¶
MarshalBinary implements the encoding.BinaryMarshaler interface.
func (Token) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface, returning a base64-encoded slice of bytes.
func (*Token) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (*Token) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface, decoding a base64-encoded slice of bytes.