M cmd/moac-pwgen/main.go => cmd/moac-pwgen/main.go +2 -2
@@ 164,11 164,11 @@ func main1() int {
func setCharsetNames(args []string) (charsetNames []string) {
var badCharsets []string
+ charsetNames = []string{"ascii"}
+
if len(args) > 0 {
charsetNames, badCharsets = sanitize.FilterStrings(args)
warnOnBadCharacters(badCharsets)
- } else {
- charsetNames = []string{"ascii"}
}
return charsetNames
M givens.go => givens.go +3 -4
@@ 222,12 222,11 @@ func (givens *Givens) MinEntropy() (entropyNeeded float64, err error) {
if givens.Time > 0 {
timeBound := math.Log2(givens.Time * givens.GuessesPerSecond)
- entropyNeeded = math.Min(energyBound, timeBound)
- } else {
- entropyNeeded = energyBound
+
+ return math.Min(energyBound, timeBound), nil
}
- return entropyNeeded, nil
+ return energyBound, nil
}
// MinEntropyQuantum is equivalent to MinEntropy, but accounts for
M pwgen/genpw_test.go => pwgen/genpw_test.go +3 -1
@@ 289,7 289,9 @@ func pwOnlyUsesCharsets(cs charsets.CharsetCollection, password []rune) (rune, b
for i, allowedChar := range allowedRunes {
if pwChar == allowedChar {
break
- } else if i == len(allowedRunes)-1 {
+ }
+
+ if i == len(allowedRunes)-1 {
return pwChar, false
}
}
M pwgen/pwgen.go => pwgen/pwgen.go +4 -2
@@ 146,9 146,11 @@ func buildFixedLengthPw(
if i := indexOf(specialIndexes, currentLength); i >= 0 {
addRuneToEnd(pwBuilder, cs[i].Runes()) // one of each charset @ a special index
specialI++
- } else {
- addRuneToEnd(pwBuilder, combinedCharset)
+
+ continue
}
+
+ addRuneToEnd(pwBuilder, combinedCharset)
}
return []rune(pwBuilder.String())