pwgen

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2021 License: MPL-2.0 Imports: 10 Imported by: 0

Documentation

Overview

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

Index

Constants

This section is empty.

Variables

View Source
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.

Jump to

Keyboard shortcuts

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