aboutsummaryrefslogtreecommitdiffhomepage
path: root/test.c
diff options
context:
space:
mode:
authortony <tsyrogit@users.noreply.github.com>2016-10-24 09:56:16 +0100
committertony <tsyrogit@users.noreply.github.com>2016-10-24 09:56:16 +0100
commitebfeb8abdd6a503e880095f07f5cba76dcfcc0d9 (patch)
tree79cedaeb8661b8cb76e9f22acf6e37f1d763e66f /test.c
parent6040c15aedbeac09764b85e5949b0e71b5c36a81 (diff)
downloadzxcvbn-c-ebfeb8abdd6a503e880095f07f5cba76dcfcc0d9.tar.gz
Add extra entropy if a password is made from multiple matches, also move some controlling #defines to beginning of zxcvbn.c
Diffstat (limited to 'test.c')
-rw-r--r--test.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/test.c b/test.c
index 6d763a5..b15cbe3 100644
--- a/test.c
+++ b/test.c
@@ -33,6 +33,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <math.h>
#include <sys/time.h>
#include <zxcvbn.h>
@@ -56,13 +57,17 @@ static void CalcPass(const char *Pwd, int Quiet)
int Len, ChkLen;
struct timeval t1, t2;
ZxcMatch_t *Info, *p;
+ double m = 0.0;
gettimeofday(&t1, 0);
e = ZxcvbnMatch(Pwd, UsrDict, &Info);
gettimeofday(&t2, 0);
+ for(p = Info; p; p = p->Next)
+ m += p->Entrpy;
Len = strlen(Pwd);
- printf("Pass %s \tLength %d\tEntropy bits=%.3f log10=%.3f\n", Pwd, Len, e, e * 0.301029996);
+ m = e - m;
+ printf("Pass %s \tLength %d\tEntropy bits=%.3f log10=%.3f\tMulti-word extra bits=%.1f factor=%.1f\n", Pwd, Len, e, e * 0.301029996, m, pow(2.0,m));
p = Info;
ChkLen = 0;
while(p)