Documentation ¶
Index ¶
- type Dictionary
- func (d *Dictionary) Capitalize() string
- func (d *Dictionary) Entropy(n int) float64
- func (d *Dictionary) Length() int
- func (d *Dictionary) MaxWordLength() int
- func (d *Dictionary) MinWordLength() int
- func (d *Dictionary) Passphrase(n int) ([]string, error)
- func (d *Dictionary) SetCapitalize(s string)
- func (d *Dictionary) SetMaxWordLength(n int)
- func (d *Dictionary) SetMinWordLength(n int)
- func (d *Dictionary) Word(idx int) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dictionary ¶
type Dictionary struct {
// contains filtered or unexported fields
}
Dictionary wraps a word list and its length.
func GetDict ¶
func GetDict(lang string) *Dictionary
GetDict returns the dictionary associated with the language code lang.
func NewDictionary ¶
func NewDictionary(r io.Reader) *Dictionary
NewDictionary scans r line-by-line and returns a Dictionary. Each line in r should be a word in the dictionary. Lines beginning with a #-character are considred comments and are ignored.
func (*Dictionary) Capitalize ¶
func (d *Dictionary) Capitalize() string
Capitalize returns the current capitalizaton strategy.
func (*Dictionary) Entropy ¶
func (d *Dictionary) Entropy(n int) float64
Entropy returns the number of bits of entropy the current dictionary configuration can support.
func (*Dictionary) Length ¶
func (d *Dictionary) Length() int
Length returns the number of words in the Dictionary.
func (*Dictionary) MaxWordLength ¶
func (d *Dictionary) MaxWordLength() int
MaxWordLength returns the current max word length
func (*Dictionary) MinWordLength ¶
func (d *Dictionary) MinWordLength() int
MinWordLength returns the current minimum word length
func (*Dictionary) Passphrase ¶
func (d *Dictionary) Passphrase(n int) ([]string, error)
Passphrase returns a slice of n randomly chosen words. If the dictionary cannot support the minimum entropy, then an error is returned.
func (*Dictionary) SetCapitalize ¶
func (d *Dictionary) SetCapitalize(s string)
SetCapitalize sets the capitalization strategy. If the string passed in is not a recognized strategy, then 'none' is used.
func (*Dictionary) SetMaxWordLength ¶
func (d *Dictionary) SetMaxWordLength(n int)
SetMaxWordLength updates the maximum word length of the dictionary. Values of 0 or less are taken to mean no limit.
func (*Dictionary) SetMinWordLength ¶
func (d *Dictionary) SetMinWordLength(n int)
SetMinWordLength updates the minimum word length of the dictionary. Values of 0 or less are taken to mean no limit.
func (*Dictionary) Word ¶
func (d *Dictionary) Word(idx int) string
Word returns the word at index idx. If idx is less than 0, or greater than or equal to the number of words in the dictionary, then Word returns an empty string.