Experimental code, as well as a CLI utility of the same name for accessing some of it. https://sneak.berlin/x
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
x/cmd/pwgen.go

29 lines
526 B

package cmd
import (
"crypto/rand"
"fmt"
"math/big"
"github.com/spf13/cobra"
"sneak.berlin/x/pkg/bip39wordlist"
)
func init() {
generateCommand.AddCommand(passwordCmd)
}
var passwordCmd = &cobra.Command{
Use: "password",
Short: "Print a randomly generated password",
Run: func(cmd *cobra.Command, args []string) {
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]
}