-
Notifications
You must be signed in to change notification settings - Fork 0
/
passphrase_example_test.go
49 lines (44 loc) · 1.08 KB
/
passphrase_example_test.go
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package passgen
import (
"fmt"
)
func ExampleGetXKCDPassphrase() {
p, err := GetXKCDPassphrase(4)
if err != nil {
//handle error
}
fmt.Println(p)
}
func ExamplePassphraseGenerator() {
// Can use any PassphraseGenerator - provided or Custom
gen, err := GetXKCDPassphraseGenerator()
if err != nil {
// Handle error
}
for i := 0; i < 5; i++ {
p := gen.GeneratePassphrase(4)
fmt.Println(p)
}
}
func ExampleNewPassphraseGenerator() {
// This example will create a passphrase generator that will use 6 short words, 2 to 4 letter words, from the internal dictionary
gen, err := NewPassphraseGenerator("internal", 2, 4)
if err != nil {
// Handle error
}
for i := 0; i < 5; i++ {
p := gen.GeneratePassphrase(6)
fmt.Println(p)
}
}
func ExampleNewPassphraseGenerator_dictionaryFile() {
// This example will create a passphrase generator that will use a custom dictionary file for finding words
gen, err := NewPassphraseGenerator("path/to/dictionary", 4, 8)
if err != nil {
// Handle error
}
for i := 0; i < 5; i++ {
p := gen.GeneratePassphrase(4)
fmt.Println(p)
}
}