Skip to content

Commit

Permalink
Merge pull request #28 from vvatanabe/port-zxcvbn-v4.4.1
Browse files Browse the repository at this point in the history
port zxcvbn 4.4.1
  • Loading branch information
vvatanabe authored Dec 3, 2016
2 parents f308778 + 33f9f9e commit 35968a0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
23 changes: 11 additions & 12 deletions src/main/java/com/nulabinc/zxcvbn/Scoring.java
Original file line number Diff line number Diff line change
Expand Up @@ -97,20 +97,19 @@ private static void update(String password, Match m, int l, Optimal optimal, boo
private static void bruteforceUpdate(String password, int k, Optimal optimal, boolean excludeAdditive) {
Match m = makeBruteforceMatch(password, 0, k);
update(password, m, 1, optimal, excludeAdditive);
if (k == 0) {
return;
}
for (Map.Entry<Integer, Match> entry : optimal.m.get(k - 1).entrySet()) {
int l = entry.getKey();
Match last_m = entry.getValue();
if (last_m.pattern == Pattern.Bruteforce) {
m = makeBruteforceMatch(password, last_m.i, k);
update(password, m, l, optimal, excludeAdditive);
} else {
m = makeBruteforceMatch(password, k, k);
update(password, m, l + 1, optimal, excludeAdditive);
for (int i = 1; i <= k; i++) {
m = makeBruteforceMatch(password, i, k);
for (Map.Entry<Integer, Match> entry : optimal.m.get(i - 1).entrySet()) {
int l = entry.getKey();
Match last_m = entry.getValue();
if (last_m.pattern == Pattern.Bruteforce) {
continue;
} else {
update(password, m, l + 1, optimal, excludeAdditive);
}
}
}

}

private static List<Match> unwind(int n, Optimal optimal) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class DictionaryGuess extends BaseGuess {

@Override
public double exec(Match match) {
match.baseGuesses = (double) match.rank;
int uppercaseVariations = uppercaseVariations(match);
int l33tVariations = l33tVariations(match);
int reversedVariations = match.reversed ? 2 : 1;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/nulabinc/zxcvbn/matchers/Match.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class Match {
public final String regexName;
public final java.util.regex.Matcher regexMatch;
public final String baseToken;
public final double baseGuesses;
public final List<Match> baseMatches;
public final int repeatCount;
public final String graph;
Expand All @@ -37,6 +36,7 @@ public class Match {
public final int month;
public final int day;

public Double baseGuesses;
public Double guesses;
public Double guessesLog10;

Expand Down

0 comments on commit 35968a0

Please sign in to comment.