aboutsummaryrefslogtreecommitdiffhomepage
path: root/test.c
diff options
context:
space:
mode:
authortony <tsyrogit@users.noreply.github.com>2017-03-04 16:49:38 +0000
committertony <tsyrogit@users.noreply.github.com>2017-03-04 16:49:38 +0000
commite1eb658db2f04b9235a10d210a1ed551511bff78 (patch)
tree51333182e16c5d3ed4770e36f04acf8dc31d9f01 /test.c
parentf552a523652fbc28e88111f2d4136783cf75afc5 (diff)
downloadzxcvbn-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.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/test.c b/test.c
index f2e48d5..05dcbf7 100644
--- a/test.c
+++ b/test.c
@@ -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;
}