Go fmt
parent
8d9f9e6dde
commit
5a5b66cfbf
10
pw/pw.go
10
pw/pw.go
|
@ -1,19 +1,19 @@
|
|||
package pw
|
||||
|
||||
//go:generate go run words_generate.go
|
||||
//go:generate go run words_generate.go
|
||||
|
||||
import (
|
||||
"strings"
|
||||
"crypto/rand"
|
||||
"math/big"
|
||||
"strings"
|
||||
)
|
||||
|
||||
type Strength int
|
||||
|
||||
const (
|
||||
StrengthOnline Strength = 4
|
||||
StrengthOnline Strength = 4
|
||||
StrengthOffline Strength = 6
|
||||
StrengthCrypto Strength = 8
|
||||
StrengthCrypto Strength = 8
|
||||
)
|
||||
|
||||
type Mode int
|
||||
|
@ -30,7 +30,7 @@ type Generator struct {
|
|||
|
||||
func NewGenerator(m Mode, s Strength) Generator {
|
||||
return Generator{
|
||||
Mode: m,
|
||||
Mode: m,
|
||||
Strength: s,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,9 +4,9 @@ package main
|
|||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"os"
|
||||
|
||||
"bufio"
|
||||
"os"
|
||||
"text/template"
|
||||
"time"
|
||||
)
|
||||
|
@ -22,13 +22,13 @@ func main() {
|
|||
defer f.Close()
|
||||
|
||||
packageTemplate.Execute(f, struct {
|
||||
Timestamp time.Time
|
||||
Timestamp time.Time
|
||||
WordsShort []string
|
||||
WordsLong []string
|
||||
WordsLong []string
|
||||
}{
|
||||
Timestamp: time.Now(),
|
||||
Timestamp: time.Now(),
|
||||
WordsShort: wordsShort,
|
||||
WordsLong: wordsLong,
|
||||
WordsLong: wordsLong,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
20
pword.go
20
pword.go
|
@ -6,7 +6,7 @@ import (
|
|||
"strconv"
|
||||
|
||||
"github.com/serverwentdown/pword/pw"
|
||||
|
||||
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
|
@ -17,46 +17,46 @@ func main() {
|
|||
app.Usage = "generate secure passwords"
|
||||
app.Version = "0.1.0"
|
||||
|
||||
app.Flags = []cli.Flag {
|
||||
app.Flags = []cli.Flag{
|
||||
cli.StringFlag{
|
||||
Name: "count, c",
|
||||
Name: "count, c",
|
||||
Value: "auto",
|
||||
Usage: "Generates `NUM` passwords for you to choose from",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "1",
|
||||
Name: "1",
|
||||
Usage: "Equivalent to --count 1",
|
||||
},
|
||||
cli.BoolFlag{
|
||||
Name: "stronger",
|
||||
Name: "stronger",
|
||||
Usage: "Chooses from a list of 7,776 words instead",
|
||||
},
|
||||
}
|
||||
|
||||
app.Commands = []cli.Command{
|
||||
{
|
||||
Name: "online",
|
||||
Name: "online",
|
||||
Usage: "Generates passwords for use on websites",
|
||||
Action: func(c *cli.Context) error {
|
||||
return generate(c, pw.StrengthOnline)
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "offline",
|
||||
Name: "offline",
|
||||
Usage: "Generates passwords for use offline (laptops, encrypted drives)",
|
||||
Action: func(c *cli.Context) error {
|
||||
return generate(c, pw.StrengthOffline)
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "crypto",
|
||||
Name: "crypto",
|
||||
Usage: "Generates extremely secure passwords",
|
||||
Action: func(c *cli.Context) error {
|
||||
return generate(c, pw.StrengthCrypto)
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "recall",
|
||||
Name: "recall",
|
||||
Usage: "Utility with autocomplete to help you recall passwords",
|
||||
Action: func(c *cli.Context) error {
|
||||
return recall(c)
|
||||
|
@ -82,7 +82,7 @@ func generate(c *cli.Context, strength pw.Strength) error {
|
|||
if c.GlobalBool("stronger") {
|
||||
mode = pw.ModeLong
|
||||
}
|
||||
|
||||
|
||||
g := pw.NewGenerator(mode, strength)
|
||||
|
||||
for i := 0; i < count; i++ {
|
||||
|
|
Loading…
Reference in New Issue