Documentation ¶
Overview ¶
Package tokengen provides a simple way to generate secure tokens of any length from any character set. Allowing for easy password, url, and token generation.
Index ¶
Constants ¶
const ( // Base62 [A-Za-z0-9] Base62 = `0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz` // Base64 [A-Za-z0-9+/] Base64 = Base62 + `+/` // DefaultCharset Base62 DefaultCharset = Base62 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TokenProvider ¶
TokenProvider is a simple interface for abstracting token provisioning.
type Tokengen ¶
type Tokengen struct {
// contains filtered or unexported fields
}
Tokengen implements TokenProvider and contains the configuration for generating cryptographically secure tokens.
func (Tokengen) GenerateToken ¶
GenerateToken will provide a string of letters, picked at random from the given character set, with even distribution of runes from the set GenerateToken relies on the crypto/rand package for it's random data source, rather than the math package, so is ideally suited for secure uses such as password, token and url generation.
func GenerateOneTimePassword() (string, error){ tokengen, err := tokengen.New(tokengen.DefaultCharset, 12) if err != nil { return ``, err } return tokengen.GenerateToken() }