Documentation ¶
Overview ¶
Package: randstr provides a function to generate random strings.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // PasswordPolicyLength is a password policy that checks if the password is a certain length PasswordPolicyLength = func(length int) PasswordPolicy { return func(password string) bool { return len(password) >= length } } // PasswordPolicyLowercase is a password policy that checks if the password contains a lowercase character PasswordPolicyLowercase = func() PasswordPolicy { return func(password string) bool { return strings.ContainsAny(password, lowercase) } } // PasswordPolicyUppercase is a password policy that checks if the password contains an uppercase character PasswordPolicyUppercase = func() PasswordPolicy { return func(password string) bool { return strings.ContainsAny(password, uppercase) } } // PasswordPolicyNumbers is a password policy that checks if the password contains a number PasswordPolicyNumbers = func() PasswordPolicy { return func(password string) bool { return strings.ContainsAny(password, numbers) } } // PasswordPolicySymbols is a password policy that checks if the password contains a symbol PasswordPolicySymbols = func() PasswordPolicy { return func(password string) bool { return strings.ContainsAny(password, symbols) } } )
Functions ¶
This section is empty.
Types ¶
type Generator ¶
func NewCustomGenerator ¶
NewDefaultGenerator returns a new Custom generator.
func NewDefaultGenerator ¶
func NewDefaultGenerator() Generator
NewDefaultGenerator returns a new Default generator.
func NewIDGenerator ¶
func NewIDGenerator() Generator
NewIDGenerator returns a new ID generator.
The ID generator creates a string using alphanumeric characters.
func NewPasswordGenerator ¶
func NewPasswordGenerator(policies ...PasswordPolicy) Generator
NewPasswordGenerator creates a new password generator
The password generator creates a string using alphanumeric characters and symbols.
type PasswordPolicy ¶ added in v0.1.1
PasswordPolicy is a function that checks if a password is valid
Click to show internal directories.
Click to hide internal directories.