|
@@ -30,9 +30,6 @@ func main() {
|
|
|
var usedCharsets[] string
|
|
|
var possibleSymbols int = 0
|
|
|
|
|
|
- var passphrase string
|
|
|
- var words int
|
|
|
-
|
|
|
charsets = make(map[string]string)
|
|
|
charsets["Numbers"] = "0123456789"
|
|
|
charsets["Lowercase"] = "abcdefghijklmnopqrstuvwxyz"
|
|
@@ -41,16 +38,13 @@ func main() {
|
|
|
charsets["Space"] = " "
|
|
|
charsets["Extended ASCII"] = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ"
|
|
|
|
|
|
- flag.StringVar(&passphrase, "diceware", "", "a diceware passphrase")
|
|
|
- flag.IntVar(&words, "words", 0, "How many words")
|
|
|
- flag.StringVar(&passphrase, "random", "", "a random string password")
|
|
|
- flag.StringVar(&passphrase, "insecure", "", "a human invented password")
|
|
|
dicewareCommand := flag.NewFlagSet("diceware", flag.ExitOnError)
|
|
|
- passphraseFlag := dicewareCommand.String("passphrase", "", "the passphrase")
|
|
|
+ dicewarePassphraseFlag := dicewareCommand.String("passphrase", "", "the passphrase")
|
|
|
wordsFlag := dicewareCommand.Int("words", 0, "number of words in passphrase")
|
|
|
dictSizeFlag := dicewareCommand.Int("dictSize", 0, "number of words in dictionary")
|
|
|
|
|
|
randomCommand := flag.NewFlagSet("random", flag.ExitOnError)
|
|
|
+ randomPassphraseFlag := randomCommand.String("password", "", "the password")
|
|
|
|
|
|
insecureCommand := flag.NewFlagSet("insecure", flag.ExitOnError)
|
|
|
insecureWords := insecureCommand.Int("words", 0, "number of words in invented passphrase")
|
|
@@ -74,7 +68,7 @@ func main() {
|
|
|
}
|
|
|
|
|
|
if dicewareCommand.Parsed() {
|
|
|
- if *passphraseFlag == "" {
|
|
|
+ if *dicewarePassphraseFlag == "" {
|
|
|
dicewareCommand.Usage()
|
|
|
return
|
|
|
}
|
|
@@ -86,15 +80,19 @@ func main() {
|
|
|
dicewareCommand.Usage()
|
|
|
return
|
|
|
}
|
|
|
- entropy := math.Log2(math.Pow(float64(*dictSizeFlag), float64(*wordsFlag)))
|
|
|
- fmt.Println("\nPassphrase entropy:", entropy)
|
|
|
+ entropy := math.Log2(math.Pow(float64(*dictSizeFlag), float64(*wordsFlag)))
|
|
|
+ fmt.Println("\nPassphrase entropy:", entropy)
|
|
|
}
|
|
|
|
|
|
if randomCommand.Parsed() {
|
|
|
- passphraseLength := len(passphrase)
|
|
|
+ if *randomPassphraseFlag == "" {
|
|
|
+ randomCommand.Usage()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ passphraseLength := len(*randomPassphraseFlag)
|
|
|
|
|
|
for key, value := range charsets {
|
|
|
- if strings.ContainsAny(passphrase, value) {
|
|
|
+ if strings.ContainsAny(*randomPassphraseFlag, value) {
|
|
|
possibleSymbols += len(value)
|
|
|
usedCharsets = append(usedCharsets, key)
|
|
|
}
|