password

package
v2.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*Password)

Option is a functional option type for configuring password generation.

func WithLength

func WithLength(length int) Option

WithLength sets the length of the password (8–128).

func WithLower

func WithLower() Option

WithLower enables or disables lowercase letters in the password.

func WithNumbers

func WithNumbers() Option

WithNumbers enables or disables numeric characters in the password.

func WithSpecial

func WithSpecial() Option

WithSpecial enables or disables special characters in the password.

func WithUpper

func WithUpper() Option

WithUpper enables or disables uppercase letters in the password.

type Password

type Password struct {
	// contains filtered or unexported fields
}

Password holds configuration for generating passwords.

func NewPassword

func NewPassword(opts ...Option) *Password

NewPassword constructs a Password with provided options. By default, it creates a password of length 8 with no character types enabled.

func (*Password) Generate

func (p *Password) Generate() (string, error)

Generate builds a password using the configured options. It ensures at least one character from each enabled category is included.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL