Documentation ¶
Overview ¶
Package diceware provides an implementation of the diceware passphrase generation method.
Index ¶
Constants ¶
const ( // DefaultExtra is the default value for the extra character. An extra can // be added to a passphrase to increase security without adding another // word. It isn't required by default. DefaultExtra = false // DefaultWords is the default amount of words used to build a passphrase. // This is set to a sensitive default. // Ref: https://diceware.blogspot.de/2014/03/time-to-add-word.html DefaultWords = 6 // DefaultValidate is the default value for the validation step. DefaultValidate = true // MinPhraseLength is the smallest amount of characters allowed in a // passphrase to pass the validation. Since generation is random, there is a // very small chance of getting a passphrase which has less than 17 // characters in total which IS NOT considered save. // Ref: http://world.std.com/~reinhold/dicewarefaq.html#14characters MinPhraseLength = 17 // MinWords is the required amount of words used to build a passphrase. This // values exists just for convenience and it IS NOT SAFE to use a one word // passphrase! MinWords = 1 )
Variables ¶
var ( // ErrInvalidWordCount is raised when the specified amount of words drops // below the MinWords constant. ErrInvalidWordCount = errors.New("The amount of words is invalid (drops below the value defined by MinWords)!") // ErrValidationFailed is raised when the generated passphrase doesn't met // the default security standards. ErrValidationFailed = errors.New("Invalid passphrase was generated! Use the Regenerate() method to trigger generation with the same settings.") )
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(p *Passphrase) error
An Option serves as a functional parameter which can be used to costumize the generation of the passphrase.
func Extra ¶
Extra is an Option that specifies whaether an extra will be added to the passphrase or not.
type Passphrase ¶
type Passphrase struct {
// contains filtered or unexported fields
}
A Passphrase is a diceware passphrase. It is build from a handful of words that are randomly picked from a list of words. Ref: http://world.std.com/~reinhold/diceware.html
func NewPassphrase ¶
func NewPassphrase(options ...Option) (*Passphrase, error)
NewPassphrase defines, generates, validates and returns a new diceware passphrase.
func (Passphrase) Humanize ¶
func (p Passphrase) Humanize() string
Humanize will return a human readable string which has a whitspace between each word.
func (*Passphrase) Regenerate ¶
func (p *Passphrase) Regenerate() error
Regenerate will generate the passphrase from scratch but keep the originally provided parameters.
func (Passphrase) String ¶
func (p Passphrase) String() string
String implements the Stringer interface.
func (*Passphrase) Validate ¶
func (p *Passphrase) Validate() bool
Validate verifies that the passphrase mets certain standards like a secure length and word count.