This commit is contained in:
parent
52aedf636f
commit
5a5577c7a5
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1 @@
|
||||
/sn
|
||||
/x
|
||||
|
14
cmd/generate.go
Normal file
14
cmd/generate.go
Normal file
@ -0,0 +1,14 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(generateCommand)
|
||||
}
|
||||
|
||||
var generateCommand = &cobra.Command{
|
||||
Use: "generate",
|
||||
Short: "Generate things",
|
||||
}
|
20
cmd/pwgen.go
20
cmd/pwgen.go
@ -1,17 +1,29 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"math/big"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"sneak.berlin/x/pkg/bip39wordlist"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(pwgenCmd)
|
||||
generateCommand.AddCommand(passwordCmd)
|
||||
}
|
||||
|
||||
var pwgenCmd = &cobra.Command{
|
||||
Use: "pwgen",
|
||||
var passwordCmd = &cobra.Command{
|
||||
Use: "password",
|
||||
Short: "Print a randomly generated password",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
panic("unimplemented")
|
||||
fmt.Printf("%s\n", randomPassword())
|
||||
},
|
||||
}
|
||||
|
||||
func randomPassword() string {
|
||||
wl := bip39wordlist.WordListEnglish
|
||||
count := len(wl)
|
||||
r, err := rand.Int(rand.Reader, big.Int(count))
|
||||
return wl[r]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user