Skip to content

Commit

Permalink
Improve wordlist entropy
Browse files Browse the repository at this point in the history
  • Loading branch information
hermo committed May 23, 2024
1 parent ed47f6e commit b572c51
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions entropy.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,19 @@ func bruteForceEntropy(password string) float64 {

// wordlistEntropy calculates the entropy of a password based on wordlist size
func wordlistEntropy(password string, separator rune, wordlistSize int) float64 {
// count the number of wordCount in the password. exclude one word.
wordCount := 0
wordCount := 0 // Initialize to 0 to account for randomly generated passwords
for _, c := range password {
if c == separator {
wordCount++
}
}
wordsEnt := float64(wordCount) * math.Log2(float64(wordlistSize))

// calculate entropy increase from the separator. there are 3 separators and they are always -
separatorEnt := math.Log2(3)
// calculate entropy increase from the separator. Assuming there are 3 possible separators (e.g., '-', '_', and '.')
separatorEnt := math.Log2(3) * float64(wordCount-1) // there are (wordCount-1) separators

// one word is always 3 characters long and contains uppercase letters and one or more digits
randomEnt := 3 * math.Log2(36)
randomEnt := 3 * math.Log2(36) // 26 uppercase letters + 10 digits = 36 possible characters per position

return wordsEnt + separatorEnt + randomEnt
}
Expand Down

0 comments on commit b572c51

Please sign in to comment.