password

package
v0.2.11 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxPasswordLen defines the upper bound for password generation length.
	MaxPasswordLen = 1024
)

Variables

View Source
var (
	// ProfileParanoid defines 64 characters password with 10 symbol and 10 digits
	// with character repetition.
	//
	// Sample output: 2FXUH5pSW2Kad._5Ok:89f8|w?I&ftJKei+QFf\5`j9B+ykSFrCSUvciiR6KLEBv
	ProfileParanoid = &Profile{Length: 64, NumDigits: 10, NumSymbol: 10, NoUpper: false, AllowRepeat: true}

	// ProfileNoSymbol defines 32 characters password 10 digits with character repetition.
	//
	// Sample output: N9ITdLnPk2cx4Wme7i24HeGs786cz8Zz
	ProfileNoSymbol = &Profile{Length: 32, NumDigits: 10, NumSymbol: 0, NoUpper: false, AllowRepeat: true}

	// ProfileStrong defines 32 characters password with 10 symbols and 10 digits
	// with character repetition.
	//
	// Sample output: +75DRm71GEK?Bb03KGU!3_=7^9[N8`-`
	ProfileStrong = &Profile{Length: 32, NumDigits: 10, NumSymbol: 10, NoUpper: false, AllowRepeat: true}
)

Functions

func FromProfile

func FromProfile(p *Profile) (string, error)

FromProfile uses given profile to generate a password which profile constraints.

func Generate

func Generate(length, numDigits, numSymbol int, noUpper, allowRepeat bool) (string, error)

Generate a custom password

func NoSymbol

func NoSymbol() (string, error)

NoSymbol generates a 32 character length password with 10 digits count, no symbol, with all cases, and character repeat.

func Paranoid

func Paranoid() (string, error)

Paranoid generates a 64 character length password with 10 digits count, 10 symbol count, with all cases, and character repeat.

func Strong

func Strong() (string, error)

Strong generates a 32 character length password with 10 digits count, 10 symbol count, with all cases, and character repeat.

Types

type Profile

type Profile struct {
	// Password total legnth.
	Length int
	// Digit count in generated password.
	NumDigits int
	// Symbol count in generated password.
	NumSymbol int
	// Allow/Disallow uppercase.
	NoUpper bool
	// Allow/Disallow character repetition.
	AllowRepeat bool
}

Profile holds password generation settings

Jump to

Keyboard shortcuts

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