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
type TokenConfig ¶ added in v0.2.0
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
Click to show internal directories.
Click to hide internal directories.