Documentation ¶
Overview ¶
Package pwgen allows generating random passwords given charsets, length limits, and target entropy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidLenBounds = errors.New("bad length bounds")
ErrInvalidLenBounds represents bad minLen/maxLen values.
Functions ¶
func BuildCharsets ¶ added in v1.2.0
BuildCharsets creates the charsets to use when generating passwords. It de-duplicates custom charsets and ensures that there is no overlap between different charsets. It replaces "ascii" and "latin" aliases with their individual components, and checks each charset named in charsetsNamed against entropy.Constants. Named charsets that don't correspond to entries in entropy.Constants are treated as elements of a new custom charset.
func GenPW ¶
GenPW generates a random password using characters from the charsets enumerated by charsetsEnumerated. At least one element of each charset is used. Available charsets are "lowercase", "uppercase", "numbers", "symbols", "latin1", latinExtendedA", "latinExtendedB", and "ipaExtensions". "latin" is also available: it's equivalent to specifying "latin1 latinExtendedA latinExtendedB ipaExtensions". Anything else will be treated as a string containing runes of a new custom charset to use. 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 ¶
This section is empty.