secrets

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigDefault = TokenConfig{
	Len:    30,
	CrcLen: 6,
	Prefix: "",
}

Functions

This section is empty.

Types

type Token

type Token struct {
	Valid bool
	// contains filtered or unexported fields
}

Token is a cryptographically secure generated token with crc

func (Token) Base62

func (t Token) Base62() string

func (Token) Err added in v0.2.0

func (t Token) Err() error

func (Token) Len

func (t Token) Len() int

func (Token) Prefix added in v0.2.0

func (t Token) Prefix() string

func (Token) String

func (t Token) String() string

type TokenConfig added in v0.2.0

type TokenConfig struct {
	Len    int
	CrcLen int
	Prefix string
}

type TokenFactory added in v0.2.0

type TokenFactory struct {
	// contains filtered or unexported fields
}

func NewTokenFactory added in v0.2.0

func NewTokenFactory(config TokenConfig) *TokenFactory

func (*TokenFactory) Checksum added in v0.2.0

func (f *TokenFactory) Checksum(data []byte) string

Checksum calculates the crc32 sum of the token

func (*TokenFactory) FromBase62 added in v0.2.0

func (f *TokenFactory) FromBase62(s string) Token

FromBase62 builds Token object from a base62-encoded string; also validates the crc32

func (*TokenFactory) FromString added in v0.2.0

func (f *TokenFactory) FromString(s string) Token

FromString builds Token object from a given string; also validates the crc32

func (*TokenFactory) NewToken added in v0.2.0

func (f *TokenFactory) NewToken() Token

Tokens contain a CRC32 checksum controlled by the CrcLen parameter. When using FromString() or FromBase62(), the factory validates tokens with their crc32 based on the factory config.

func (*TokenFactory) Validate added in v0.2.0

func (f *TokenFactory) Validate(t Token) bool

Validate returns true if the crc is valid

Jump to

Keyboard shortcuts

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