diff options
author | tony <tsyrogit@users.noreply.github.com> | 2017-03-04 16:49:38 +0000 |
---|---|---|
committer | tony <tsyrogit@users.noreply.github.com> | 2017-03-04 16:49:38 +0000 |
commit | e1eb658db2f04b9235a10d210a1ed551511bff78 (patch) | |
tree | 51333182e16c5d3ed4770e36f04acf8dc31d9f01 /test.c | |
parent | f552a523652fbc28e88111f2d4136783cf75afc5 (diff) | |
download | zxcvbn-c-e1eb658db2f04b9235a10d210a1ed551511bff78.tar.gz |
Calculate the required size for PossChars based on the dictionary used. The fix
for this by hannob in commit ad2ef761 works for the current dictionary, but would
fail if a dictionary is used with 49 or more possible characters for one of its nodes.
Diffstat (limited to 'test.c')
-rw-r--r-- | test.c | 25 |
1 files changed, 19 insertions, 6 deletions
@@ -124,6 +124,8 @@ int DoChecks(char *file) int y = 0; int w = 0; int r = 0; + int Less = 0; + int More = 0; FILE *f = fopen(file, "r"); if (f == NULL) { @@ -185,17 +187,28 @@ int DoChecks(char *file) e = ZxcvbnMatch(Pwd, UsrDict, 0); x = e / Ent; /* More than 1% difference is a fail. */ - if ((x > 1.01) || (x < 1.0/1.01)) + if (x > 1.01) { - printf("Line %2d Calculated entropy %5.2f, expected %5.2f <%s>\n", y, e, Ent, Pwd); - r = 1; - break; + ++More; + if (r < 10) + { + printf("Line %2d Calculated entropy %5.2f, expected %5.2f <%s>\n", y, e, Ent, Pwd); + ++r; + } + } + else if (x < 1.0/1.01) + { + ++Less; + if (r < 10) + { + printf("Line %2d Calculated entropy %5.2f, expected %5.2f <%s>\n", y, e, Ent, Pwd); + ++r; + } } ++w; } fclose(f); - if (!r) - printf("Tested %d words\n", w); + printf("Tested %d words, %d with low entropy, %d with high\n", w, Less, More); return r; } |