Skip to content

Commit

Permalink
abandon "entropy" terminology in favor of "guesses"
Browse files Browse the repository at this point in the history
* it is cleaner to work with guess estimates directly instead of their logs
* previous use of "entropy", while common, was mathematically sloppy
  • Loading branch information
lowe committed Sep 25, 2015
1 parent b87994f commit a1be663
Show file tree
Hide file tree
Showing 5 changed files with 237 additions and 324 deletions.
2 changes: 1 addition & 1 deletion src/main.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ zxcvbn = (password, user_inputs = []) ->
sanitized_inputs.push arg.toString().toLowerCase()
matching.set_user_input_dictionary sanitized_inputs
matches = matching.omnimatch password
result = scoring.minimum_entropy_match_sequence password, matches
result = scoring.most_guessable_match_sequence password, matches
result.calc_time = time() - start
result

Expand Down
12 changes: 6 additions & 6 deletions src/matching.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -345,25 +345,25 @@ matching =
base_token = match[1]
[i, j] = [match.index, match.index + match[0].length - 1]
# recursively match and score the base string
base_analysis = scoring.minimum_entropy_match_sequence(
base_analysis = scoring.most_guessable_match_sequence(
base_token
@omnimatch base_token
)
base_matches = base_analysis.match_sequence
base_entropy = base_analysis.entropy
base_guesses = base_analysis.guesses
matches.push
pattern: 'repeat'
i: i
j: j
token: match[0]
base_token: base_token
base_entropy: base_entropy
base_guesses: base_guesses
base_matches: base_matches
repeat_count: match[0].length / base_token.length
lastIndex = j + 1
matches

sequence_match: (password) ->
min_sequence_length = 3 # TODO allow 2-char sequences?
matches = []
for sequence_name, sequence of SEQUENCES
for direction in [1, -1]
Expand All @@ -382,7 +382,7 @@ matching =
j += 1
sequence_position = next_sequence_position
j -= 1
if j - i + 1 >= min_sequence_length
if j - i + 1 > 1
matches.push
pattern: 'sequence'
i: i
Expand Down Expand Up @@ -478,7 +478,7 @@ matching =
candidates.push dmy if dmy?
continue unless candidates.length > 0
# at this point: different possible dmy mappings for the same i,j substring.
# match the candidate date that has smallest entropy: a year closest to 2000.
# match the candidate date that likely takes the fewest guesses: a year closest to 2000.
# (scoring.REFERENCE_YEAR).
#
# ie, considering '111504', prefer 11-15-04 to 1-1-1504
Expand Down
Loading

0 comments on commit a1be663

Please sign in to comment.