generator

package
Version: v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2022 License: MIT Imports: 4 Imported by: 7

Documentation

Index

Constants

View Source
const (
	// LengthWeak weak length password
	LengthWeak uint = 6

	// LengthOK ok length password
	LengthOK uint = 12

	// LengthStrong strong length password
	LengthStrong uint = 24

	// LengthVeryStrong very strong length password
	LengthVeryStrong uint = 36

	// DefaultLetterSet is the letter set that is defaulted to - just the
	// alphabet
	DefaultLetterSet = "abcdefghijklmnopqrstuvwxyz"

	// DefaultLetterAmbiguousSet are letters which are removed from the
	// chosen character set if removing similar characters
	DefaultLetterAmbiguousSet = "ijlo"

	// DefaultNumberSet the default symbol set if character set hasn't been
	// selected
	DefaultNumberSet = "0123456789"

	// DefaultNumberAmbiguousSet are the numbers which are removed from the
	// chosen character set if removing similar characters
	DefaultNumberAmbiguousSet = "01"

	// DefaultSymbolSet the default symbol set if character set hasn't been
	// selected
	DefaultSymbolSet = "!$%^&*()_+{}:@[];'#<>?,./|\\-=?"

	// DefaultSymbolAmbiguousSet are the symbols which are removed from the
	// chosen character set if removing ambiguous characters
	DefaultSymbolAmbiguousSet = "<>[](){}:;'/|\\,"
)

Variables

View Source
var (
	// DefaultConfig is the default configuration, defaults to:
	//    - length = 24
	//    - Includes symbols, numbers, lowercase and uppercase letters.
	//    - Excludes similar and ambiguous characters
	DefaultConfig = Config{
		Length:                     LengthStrong,
		IncludeSymbols:             true,
		IncludeNumbers:             true,
		IncludeLowercaseLetters:    true,
		IncludeUppercaseLetters:    true,
		ExcludeSimilarCharacters:   true,
		ExcludeAmbiguousCharacters: true,
	}

	// ErrConfigIsEmpty is the error if the config given is empty
	ErrConfigIsEmpty = errors.New("config is empty")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Length is the length of password to generate
	Length uint

	// CharacterSet is the setting to manually set the
	// character set
	CharacterSet string

	// IncludeSymbols is the setting to include symbols in
	// the character set
	// i.e. !"£*
	IncludeSymbols bool

	// IncludeNumbers is the setting to include number in
	// the character set
	// i.e. 1234
	IncludeNumbers bool

	// IncludeLowercaseLetters is the setting to include
	// lowercase letters in the character set
	// i.e. abcde
	IncludeLowercaseLetters bool

	// IncludeUppercaseLetters is the setting to include
	// uppercase letters in the character set
	// i.e. ABCD
	IncludeUppercaseLetters bool

	// ExcludeSimilarCharacters is the setting to exclude
	// characters that look the same in the character set
	// i.e. i1jIo0
	ExcludeSimilarCharacters bool

	// ExcludeAmbiguousCharacters is the setting to exclude
	// characters that can be hard to remember or symbols
	// that are rarely used
	// i.e. <>{}[]()/|\`
	ExcludeAmbiguousCharacters bool
}

Config is the config struct to hold the settings about what type of password to generate

type Generator

type Generator struct {
	*Config
}

Generator is what generates the password

func New

func New(config *Config) (*Generator, error)

New returns a new generator

func NewWithDefault

func NewWithDefault() (*Generator, error)

NewWithDefault returns a new generator with the default config

func (Generator) Generate

func (g Generator) Generate() (*string, error)

Generate generates one password with length set in the config

func (Generator) GenerateMany

func (g Generator) GenerateMany(amount uint) ([]string, error)

GenerateMany generates multiple passwords with length set in the config

func (Generator) GenerateManyWithLength

func (g Generator) GenerateManyWithLength(amount, length uint) ([]string, error)

GenerateManyWithLength generates multiple passwords with set length

func (Generator) GenerateWithLength

func (g Generator) GenerateWithLength(length uint) (*string, error)

GenerateWithLength generate one password with set length

Source Files

Jump to

Keyboard shortcuts

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