Documentation
¶
Index ¶
- Variables
- func Generate(options ...GenerateOption) (string, error)
- func MustGenerate(options ...GenerateOption) string
- func Verify(password string, options ...VerifyOption) error
- type GenerateConfig
- type GenerateOption
- func GenerateWithCustomCharsetOption(charset string) GenerateOption
- func GenerateWithExcludedCharsOption(chars string) GenerateOption
- func GenerateWithLengthOption(length int) GenerateOption
- func GenerateWithoutLowerOption() GenerateOption
- func GenerateWithoutNumbersOption() GenerateOption
- func GenerateWithoutSpecialOption() GenerateOption
- func GenerateWithoutUpperOption() GenerateOption
- type VerifyConfig
- type VerifyOption
- func VerifyWithMaxLengthOption(length int) VerifyOption
- func VerifyWithMinLengthOption(length int) VerifyOption
- func VerifyWithoutLowercaseOption() VerifyOption
- func VerifyWithoutNumbersOption() VerifyOption
- func VerifyWithoutSpecialOption() VerifyOption
- func VerifyWithoutUppercaseOption() VerifyOption
Constants ¶
This section is empty.
Variables ¶
var (
ErrInvalidCharset = errors.New("invalid charset: no characters available for password generation")
)
Functions ¶
func Generate ¶
func Generate(options ...GenerateOption) (string, error)
Generate creates a random password based on the specified options
func MustGenerate ¶
func MustGenerate(options ...GenerateOption) string
MustGenerate is a helper that wraps Generate and panics if an error occurs
func Verify ¶
func Verify(password string, options ...VerifyOption) error
Verify Validate password against common criteria
Types ¶
type GenerateConfig ¶
type GenerateConfig struct { Length int UseUpper bool UseLower bool UseNumbers bool UseSpecial bool CustomCharset string ExcludeChars string }
GenerateConfig holds password generation settings
type GenerateOption ¶
type GenerateOption func(*GenerateConfig)
GenerateOption is a function that modifies GenerateConfig
func GenerateWithCustomCharsetOption ¶
func GenerateWithCustomCharsetOption(charset string) GenerateOption
GenerateWithCustomCharsetOption sets a custom character set for password generation
func GenerateWithExcludedCharsOption ¶
func GenerateWithExcludedCharsOption(chars string) GenerateOption
GenerateWithExcludedCharsOption specifies characters to exclude from password generation
func GenerateWithLengthOption ¶
func GenerateWithLengthOption(length int) GenerateOption
GenerateWithLengthOption sets the desired length for the generated password
func GenerateWithoutLowerOption ¶
func GenerateWithoutLowerOption() GenerateOption
GenerateWithoutLowerOption excludes lowercase letters from password generation
func GenerateWithoutNumbersOption ¶
func GenerateWithoutNumbersOption() GenerateOption
GenerateWithoutNumbersOption excludes numbers from password generation
func GenerateWithoutSpecialOption ¶
func GenerateWithoutSpecialOption() GenerateOption
GenerateWithoutSpecialOption excludes special characters from password generation
func GenerateWithoutUpperOption ¶
func GenerateWithoutUpperOption() GenerateOption
GenerateWithoutUpperOption excludes uppercase letters from password generation
type VerifyConfig ¶
type VerifyConfig struct { MinLength int MaxLength int RequireUppercase bool RequireLowercase bool RequireNumbers bool RequireSpecial bool }
VerifyConfig holds password validation settings
type VerifyOption ¶
type VerifyOption func(*VerifyConfig)
VerifyOption is a function that modifies VerifyConfig
func VerifyWithMaxLengthOption ¶
func VerifyWithMaxLengthOption(length int) VerifyOption
VerifyWithMaxLengthOption sets maximum password length
func VerifyWithMinLengthOption ¶
func VerifyWithMinLengthOption(length int) VerifyOption
VerifyWithMinLengthOption sets minimum password length
func VerifyWithoutLowercaseOption ¶
func VerifyWithoutLowercaseOption() VerifyOption
VerifyWithoutLowercaseOption removes lowercase requirement
func VerifyWithoutNumbersOption ¶
func VerifyWithoutNumbersOption() VerifyOption
VerifyWithoutNumbersOption removes numbers requirement
func VerifyWithoutSpecialOption ¶
func VerifyWithoutSpecialOption() VerifyOption
VerifyWithoutSpecialOption removes special characters requirement
func VerifyWithoutUppercaseOption ¶
func VerifyWithoutUppercaseOption() VerifyOption
VerifyWithoutUppercaseOption removes uppercase requirement