package pwgen

import "git.sr.ht/~seirdy/moac/v2/pwgen"

Package pwgen allows generating random passwords given charsets, length limits, and target entropy.

Index

Variables

var ErrInvalidLenBounds = errors.New("bad length bounds")

ErrInvalidLenBounds represents bad minLen/maxLen values.

Functions

func GenPW

func GenPW(pwr PwRequirements) (string, error)

GenPW generates a random password using characters from the charsets enumerated by charsetsEnumerated. At least one element of each charset is used. If entropyWanted is 0, the generated password has at least 256 bits of entropy; otherwise, it has entropyWanted bits of entropy. minLen and maxLen are ignored when set to zero; otherwise, they set lower/upper bounds on password character count and override entropyWanted if necessary. GenPW will *not* strip any characters from given charsets that may be undesirable (newlines, control characters, etc.), and does not preserve grapheme clusters.

Types

type PwRequirements

type PwRequirements struct {
	CharsetsWanted charsets.CharsetCollection
	TargetEntropy  float64
	MinLen, MaxLen int
}

PwRequirements holds the parameters used for password generation. These include charsets to pick from and target strength.

Source Files

indexing.go pwgen.go

Version
v2.0.2 (latest)
Published
Oct 5, 2021
Platform
linux/amd64
Imports
10 packages
Last checked
2 weeks ago

Tools for package owners.