summaryrefslogtreecommitdiff
path: root/passphrasegen.go
blob: 89b25d26403ad631c8b3fa9e8cbe512d27c651a3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main

import (
	"flag"
	"fmt"
	"strings"

	generator "github.com/michael-ball/passphrasegen/generator"
)

var numWords = flag.Int("w", 4, "Number of words in passphrase")

func init() {
	flag.Parse()
}

func main() {
	args := flag.Args()

	wordsFile := "/usr/share/dict/words"

	if len(args) > 0 {
		wordsFile = args[0]
	}

	phraseWords, err := generator.RandomWords(wordsFile, *numWords)

	if err != nil {
		fmt.Println(err)
		return
	}

	fmt.Println(strings.Join(phraseWords, " "))
}