Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DiceWare ¶
type DiceWare struct {
// contains filtered or unexported fields
}
DiceWare generates Diceware passphrases from a loaded wordlist. The zero value is not ready for use; create one with New.
func New ¶
func New() *DiceWare
New creates a DiceWare generator with the default configuration: 6 words, no appended digits, no capitalization, no digit scattering. A wordlist must be loaded separately via Load before calling Gen.
func (*DiceWare) Configure ¶
Configure updates the generator's configuration.
words is the number of words in the generated passphrase and must be greater than zero; Configure returns an error otherwise.
digits is the number of random digits to add to the passphrase. If scattered is false, the digits are appended as a single trailing group (e.g. "word-word-word-482"); if true, they are inserted one at a time at random positions within the words themselves.
caps capitalizes the first letter of each word and lowercases the rest.
func (*DiceWare) Gen ¶
Gen generates a new passphrase using the current configuration and loaded wordlist.
A wordlist must have been loaded via Load beforehand; Gen returns an error otherwise. Gen also returns an error if the configured word count is zero or if the wordlist size is inconsistent with the configured dice code length.
func (*DiceWare) Load ¶
Load reads a Diceware wordlist from path and prepares the generator to use it, replacing any previously loaded wordlist.
The file must contain one entry per line in the form "<dice code> <word>", where the dice code is a run of digits 1-6 with a consistent length (4 to 8) across the whole file, and the total number of valid entries must exactly match 6^len(code). Lines that don't match this format (blank lines, comments, headers) are skipped.
Load returns an error if path does not exist, is a directory, or the file contains a malformed or incomplete wordlist (including duplicate dice codes).