PWGen/pwgenerator/types.go

53 lines
2.6 KiB
Go
Raw Normal View History

2022-03-02 06:24:55 -05:00
package pwgenerator
// Char is implemented as a rune.
type Char rune
// CharSet is a collection of characters (Char) but with additional methods (e.g. sort.Sort interface conformance).
type CharSet []Char
// GenOpts controls what kind of (and how many) password(s) should be generated.
type GenOpts struct {
/*
Some references below contain a reference to the character's hex ASCII.
If you need the decimal/octal/etc. reference instead, you can cross-reference
it via https://square-r00t.net/ascii.html.
*/
/*
HumanOnly avoids visually-ambiguous characters if enabled, ensuring a more readable, visually-distinguishable,
and accessible but MUCH smaller password character space (from about 220 characters to ), thus much less secure.
TODO: Get feedback on this. I feel like I'm trimming out WAY too many chars.
*/
// HumanOnly bool `json:"do_human_readable"`
// Alpha is true if letters (0x41 to 0x5a, 0x61 to 0x7a) should be included.
Alpha bool `json:"do_alpha"`
// Numeric is true if numbers (0x30 to 0x39) should be included.
Numeric bool `json:"do_numeric"`
// Symbols is true if non-alphanumeric characters (between 0x21 and 0x7e) should be included.
Symbols bool `json:"do_symbols"`
// ExtendedSymbols is true if non-alphanumeric characters in the "extended ASCII" set (0x80 to 0xff) should be included.
ExtendedSymbols bool `json:"do_extended"`
// CountUpper specifies how many uppercase letters (0x41 to 0x5a) should be specified at a minimum.
CountUpper uint `json:"uppers"`
// CountLower specifies how many lowercase letters (0x61 to 0x7a) should be specified at a minimum.
CountLower uint `json:"lowers"`
// CountSymbols specifies how many symbols (0x21 to 0x7e) should be specified at a minimum.
CountSymbols uint `json:"symbols"`
// CountExtended specifies how many extended symbols (0x80 to 0xff) should be specified at a minimum.
CountExtended uint `json:"extended"`
// DisabledChars includes characters that should NOT be included from the above selection options.
DisabledChars CharSet `json:"disabled_chars"`
// LengthMin specifies how long (in characters/bytes) each password should be at minimum. Use 0 for no minimum.
LengthMin uint `json:"length_min"`
/*
LengthMax specifies the maximum length for each password. Set to 0 for no limit
(the language has a hard limit of 18446744073709551615; this is limited to 256 for performance reasons).
*/
LengthMax uint `json:"length_max"`
// Count specifies how many passwords to generate. If 0, the default is 1.
Count uint `json:"count"`
// explicitCharset is the collection of acceptable characters as explicitly defined by the caller, if any.
explicitCharset CharSet
}