Documentation
¶
Overview ¶
Package phraser generates human readable passphrases from customizable word lists. These passphrases are great for use as temporary passwords or whenever you need a set of user-friendly random words.
Example ¶
package main
import (
"fmt"
"github.com/groundbreaker/phraser"
)
func main() {
p := phraser.New()
phrase := p.GeneratePhrase()
fmt.Println(phrase.Passphrase())
}
Output:
Example (Override) ¶
package main
import (
"fmt"
"github.com/groundbreaker/phraser"
)
func main() {
// Override the Default* vars before calling phraser.New()
// Use your own []string values, or use phraser.ParseWordList to laod it from a file.
phraser.DefaultSymbol = "#"
phraser.DefaultAdjectives = []string{"awesome"}
phraser.DefaultNouns = []string{"robots"}
p := phraser.New()
// You can also override values on the instance of phraser.
p.Adjectives = []string{"amiable"}
phrase := p.GeneratePhrase() // this sets the random values
// You can override the choosen values here as well.
phrase.Number = 42
phrase.Symbol = "?"
fmt.Println(phrase.Passphrase())
}
Output: Amiable42Robots?
Index ¶
Examples ¶
Constants ¶
const VERSION = "v1.0.2"
VERSION returns the SemVer for Package phraser.
Variables ¶
var DefaultAdjectives = []string{"adaptable", "adventurous", "affable", "affectionate", "agreeable", "ambitious", "amiable", "amusing", "brave", "bright", "calm", "careful", "charming", "communicative", "compassionate ", "conscientious", "considerate", "convivial", "courageous", "courteous", "creative", "daring", "decisive", "determined", "diligent", "diplomatic", "discreet", "dynamic", "easygoing", "emotional", "empathetic", "energetic", "enthusiastic", "exuberant", "exuberant", "faithful", "fearless", "forceful", "friendly", "funny", "generous", "gentle", "gregarious", "helpful", "honest", "humorous", "imaginative", "impartial", "independent", "intelligent", "intuitive", "inventive", "kind", "loving", "loyal", "modest", "neat", "nice", "passionate", "patient", "persistent", "persistent ", "philosophical", "pioneering", "placid", "plucky", "polite", "powerful", "practical", "profitable", "quick", "rational", "reliable", "reserved", "resourceful", "sensible", "sensitive", "shy", "sincere", "sociable", "strong", "sympathetic", "thoughtful", "tidy", "unassuming", "understanding", "versatile", "warmhearted", "willing", "witty"}
DefaultAdjectives is a list of adjectives that phraser will use by default.
var DefaultNouns = []string{"animals", "artists", "baskets", "bottles", "brothers", "champs", "children", "circles", "dangers", "details", "doors", "droids", "dwarves", "engines", "events", "experts", "feelings", "freezers", "friends", "geese", "glasses", "graffiti", "groups", "harbors", "humans", "islands", "jellies", "journeys", "judges", "letters", "linens", "loaves", "machines", "minerals", "minutes", "moments", "months", "mornings", "nations", "numbers", "offspring", "opinions", "papers", "people", "pictures", "places", "planes", "plants", "purposes", "quizzes", "reasons", "rewards", "rivers", "roads", "robots", "scarves", "scissors", "shades", "sisters", "sounds", "soups", "spoons", "springs", "squares", "stamps", "stones", "students", "summers", "systems", "tables", "tails", "tastes", "teachers", "things", "thinkers", "thoughts", "times", "trains", "trucks", "values", "watches", "weeks", "whistles", "windows", "winters", "wires", "worlds", "worms", "years", "zebras"}
DefaultNouns is a list of nouns that phraser will use by default.
var DefaultSymbol = "!"
DefaultSymbol will be used when making Phrases.
Functions ¶
func ParseWordList ¶
ParseWordList reads the words from the given path to a word list file. It returns a slice containing the words found in that file.
A word list should just be a plain text file with one word per line.
Types ¶
type Phrase ¶
Phrase contains the phrase parts and the ability to concatentate the parts into a passphrase.
func (*Phrase) Passphrase ¶
Passphrase contcatenates the phrase parts and returns a passphrase in the form of: AdjectiveNumberNounSymbol, e.g. "Amiable42Robots!".
type Phraser ¶
Phraser has two word lists, one for Adjectives and one for Nouns. It uses these words when creating passphrases.
func New ¶
func New() *Phraser
New returns a new instance of Phraser using the DefaultAdjectives and DefaultNouns. You can override these exported vars before calling New() to use your own word list.
func (*Phraser) GeneratePhrase ¶
GeneratePhrase genereates and returns a new Phrase.
func (*Phraser) RandomWord ¶
RandomWord returns a random word from the given list.