1. Søren Løvborg
  2. password-generator

Commits

Søren Løvborg  committed 55f2b25

passwordgenerator.py: Use floating point, not exact arithmetic, for estimating number of combinations.

  • Participants
  • Parent commits 8b55c01
  • Branches default

Comments (0)

Files changed (1)

File passwordgenerator.py

View file
             the real number of combinations will be higher than this estimate.
         """
 
-        allCharsCount = 0
-        combinations = 1
+        # Note: We use floating point, not exact arithmetic.
+        allCharsCount = 0.0
+        combinations = 1.0
 
         # Count combinations for the forced characters.
         for chars in self.categories:
 
     def estimateEntropy():
         combinations = g.estimateCombinations()
-        print 'More than %s combinations ~ %.1f bits of entropy.' % (combinations, math.log(combinations, 2))
+        print 'More than %.1e combinations ~ %.1f bits of entropy.' % (combinations, math.log(combinations, 2))
 
     # Parse arguments