-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbrute.c
39 lines (32 loc) · 862 Bytes
/
brute.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
#include <stdlib.h>
#include <stdio.h>
#include "key.h"
#include <time.h>
int main(int argc, char *argv[])
{
Key encrypted; // A senha criptografada.
Key T[N]; // A tabela T.
if (argc != 2)
{
fprintf(stderr, "Usage: ./brute [encrypted] < [table.txt]\n");
exit(EXIT_FAILURE);
}
encrypted = init_key((unsigned char *)argv[1]);
// Exibe a senha encriptada.
printf(" ");
print_key(encrypted);
printf("\n");
// Lê a tabela T.
unsigned char buffer[C + 1]; // Buffer temporário.
for (int i = 0; i < N; i++)
{
scanf("%s", buffer);
T[i] = init_key(buffer);
}
// Força bruta
clock_t tic = clock();
dec_forca_bruta(encrypted, T);
clock_t toc = clock();
printf("Tempo: %.3f segundos\n", (double)(toc - tic) / CLOCKS_PER_SEC);
return 0;
}