Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrEmptyCharset = errors.New("cannot generate passwords with empty charset") ErrInvalidN = errors.New("value of N exceeds valid range") ErrMinLowerCaseTooLong = errors.New("minimum number of lower-case characters requested longer than password") ErrMinUpperCaseTooLong = errors.New("minimum number of upper-case characters requested longer than password") ErrMinSymbolsTooLong = errors.New("minimum number of symbols requested longer than password") ErrNoLowerCaseInCharset = errors.New("found no lower-case characters to use in charset") ErrNoUpperCaseInCharset = errors.New("found no upper-case characters to use in charset") ErrNoSymbolsInCharset = errors.New("found no symbols to use in charset") ErrRequirementsNotMet = errors.New("minimum number of lower-case+upper-case+symbols requested longer than password") ErrZeroLenPassword = errors.New("cannot generate passwords with 0 length") )
Functions ¶
func Generate ¶ added in v0.0.7
func Generate() string
Generate generates and returns a password that follows the following rules: * uses the AllChars charset * ensures the password is 12 characters long * uses a minimum of 3 lower case characters * uses a minimum of 1 upper case character * uses one symbol character
Types ¶
type Generator ¶
type Generator interface { // Generate returns a randomly generated password. Generate() string // SetSeed overrides the seed value for the RNG. SetSeed(seed uint64) }
func NewGenerator ¶
NewGenerator returns a password generator that implements the Generator interface.
type Rule ¶ added in v0.0.3
type Rule func(g *generator)
Rule controls how the Generator/Sequencer generates passwords.
func WithCharset ¶ added in v0.0.3
WithCharset sets the Charset the Generator/Sequencer can use.
func WithLength ¶ added in v0.0.3
WithLength sets the length of the generated password.
func WithMinLowerCase ¶ added in v0.0.5
WithMinLowerCase controls the minimum number of lower case characters that can appear in the password.
Note: This works only on a Generator and is ineffective with a Sequencer.
func WithMinUpperCase ¶ added in v0.0.5
WithMinUpperCase controls the minimum number of upper case characters that can appear in the password.
Note: This works only on a Generator and is ineffective with a Sequencer.
func WithNumSymbols ¶ added in v0.0.3
WithNumSymbols controls the min/max number of symbols that can appear in the password.
Note: This works only on a Generator and is ineffective with a Sequencer.