token

package module
v0.0.0-...-7169ebe Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2017 License: Apache-2.0 Imports: 4 Imported by: 0

README

go-token GoDoc

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.

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

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

func New(length int) (Token, error)

NewToken returns a cryptographically secure pseudorandom Token of the given length (in bytes).

func (Token) MarshalBinary

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

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (Token) MarshalText

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

MarshalText implements the encoding.TextMarshaler interface, returning a base64-encoded slice of bytes.

func (*Token) Scan

func (t *Token) Scan(src interface{}) error

Scan implements the sql.Scanner interface.

func (Token) String

func (t Token) String() string

String returns a base64-encoded string.

func (*Token) UnmarshalBinary

func (t *Token) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

func (*Token) UnmarshalText

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

UnmarshalText implements the encoding.TextUnmarshaler interface, decoding a base64-encoded slice of bytes.

func (Token) Value

func (t Token) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

Jump to

Keyboard shortcuts

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