xkcdpwd

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2018 License: Apache-2.0 Imports: 11 Imported by: 0

README

xkcdpwd Build Status Coverage Status

A passphrase generator in the style of XKCD comic Password Strength.

Getting started

This project requires Go to be installed. On OS X with Homebrew you can just run brew install go. On Linux check with your distro's package manager. Alternatively, or on Windows, download the Go source or binary from golang.org.

Running it then should be as simple as:

$ make
...
▶ building executable…
$ bin/xkcdpwd

Testing

make test

To generate coverage data:

make test-coverage

Similar projects

Documentation

Index

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.

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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