M charsets/charsets.go => charsets/charsets.go +2 -2
@@ 82,7 82,7 @@ func (cs *CharsetCollection) AddDefault(newCharsets ...DefaultCharset) {
}
func (cs *CharsetCollection) addSingle(c CustomCharset) {
- for i := 0; i < len(*cs) && len(c) > 0; i++ {
+ for i := 0; i < len(*cs); i++ {
minimizeRedundancyInLatter(&(*cs)[i], &c)
}
@@ 99,7 99,7 @@ func (cs *CharsetCollection) Combined() CustomCharset {
ccBuilder.WriteString(c.String())
}
- return CustomCharset([]rune(ccBuilder.String()))
+ return []rune(ccBuilder.String())
}
// ParseCharsets creates a CharsetCollection from string identifiers.
M entropy/entropy.go => entropy/entropy.go +1 -1
@@ 54,7 54,7 @@ func findCharsetsUsed(password string) charsets.CharsetCollection {
for _, charset := range charsets.DefaultCharsets {
if strings.ContainsAny(filteredPassword, charset.String()) {
- charsetsUsed = append(charsetsUsed, charset)
+ charsetsUsed.AddDefault(charset)
filterFromString(&filteredPassword, charset.Runes())
}
}
M givens.go => givens.go +10 -8
@@ 93,6 93,15 @@ func (givens *Givens) calculatePower() {
setBottleneck(&givens.Power, powerFromComputationSpeed, powerFromEnergy)
}
+func (givens *Givens) calculateGPS() {
+ var (
+ bremermannGPS = Bremermann * givens.Mass
+ powerGPS = givens.Power / givens.EnergyPerGuess
+ )
+
+ setBottleneck(&givens.GuessesPerSecond, bremermannGPS, powerGPS)
+}
+
func (givens *Givens) calculateEnergy() {
var (
energyFromMass = givens.Mass * C * C
@@ 138,14 147,7 @@ func (givens *Givens) Populate() error {
givens.calculatePower()
- var bremermannGPS float64
-
- if givens.GuessesPerSecond == 0 && givens.Mass != 0 {
- bremermannGPS = Bremermann * givens.Mass
- }
-
- powerGPS := givens.Power / givens.EnergyPerGuess
- setBottleneck(&givens.GuessesPerSecond, bremermannGPS, powerGPS)
+ givens.calculateGPS()
givens.calculateEnergy()
M pwgen/pwgen.go => pwgen/pwgen.go +3 -3
@@ 144,7 144,8 @@ func buildFixedLengthPw(
for specialI := 0; currentLength < pwLength; currentLength++ {
if i := indexOf(specialIndexes, currentLength); i >= 0 {
- addRuneToEnd(pwBuilder, cs[i].Runes()) // one of each charset @ a special index
+ // one of each charset @ a special index
+ addRuneToEnd(pwBuilder, cs[i].Runes())
specialI++
continue
@@ 158,8 159,7 @@ func buildFixedLengthPw(
func randomlyInsertRunesTillStrong(
maxLen int, pwRunes *[]rune, entropyWanted float64, combinedCharset []rune) {
- for (maxLen == 0 || len(*pwRunes) < maxLen) &&
- entropyWanted > entropy.Entropy(string(*pwRunes)) {
+ for (len(*pwRunes) < maxLen) && entropyWanted > entropy.Entropy(string(*pwRunes)) {
addRuneAtRandLoc(pwRunes, combinedCharset)
}
}