-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
67 lines (59 loc) · 2.15 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/**
* @brief : password meter algo & best pass finder.
* @author : A.Amine.
* @date : 03/03/2017
* Source inspired from (http://www.passwordmeter.com/) but the rating methode is not exactly the same.
* Flat: Rates that add/remove in non-changing increments.
• Incr: Rates that add/remove in adjusting increments.
• Cond: Rates that add/remove depending on additional factors.
• Comp: Rates that are too complex to summarize. See source code for details.
• the struct Tool: Refers to the total number of occurrences.
• len: Refers to the total password length.
• Additional bonus scores are given for increased character variety.
• Final score is a cumulative result of all bonuses minus deductions.
• Final score is capped with a minimum of 0 and a maximum of 100.
• Score and Complexity ratings are not conditional on meeting minimum requirements.
*
* See headers files for more description...
*/
#include <stdio.h>
#include <time.h>
#include <string.h>
#include "compute.h"
#include "bench.h"
#define START_PASS_LENGTH 3
int main(void)
{
Tool t, best, worst;
size_t x = NB_BENCH, my_sz;
char rndchar[BUFF_PASS] = {'\0'};
/*init */
srand(time(NULL));
memset(&best, 0, sizeof(Tool));
memset(&worst, 0, sizeof(Tool));
worst.ratio = MAX_SCORE;
/* benchmark test by increasing lenght of password from my_sz to (MIN_LENGTH + 4) */
for (my_sz = START_PASS_LENGTH; my_sz < (MIN_LENGTH + START_PASS_LENGTH); my_sz++)
{
printf("\nTest with length = %d\n\n", my_sz);
while(x--)
{
rndmPass(rndchar, my_sz);
getGlobalScore(rndchar, &t);
/*look for the best pass*/
if (t.ratio > best.ratio)
{
memcpy(&best, &t, sizeof(Tool));
showPartial(&t);
}
/* look for the worst pass*/
if (t.ratio < worst.ratio)
memcpy(&worst, &t, sizeof(Tool));
}
x = NB_BENCH;
}
showGlobal(&best);
printf ("\nPs: the worst password was: %s global score: %d (ratio %d)", worst.password, worst.score, worst.ratio -100);
/*showGlobal(&worst);*/
return 0;
}