-
Notifications
You must be signed in to change notification settings - Fork 0
/
decoder.c
109 lines (78 loc) · 1.91 KB
/
decoder.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
char character;
int pass;
}dict;
void extract(int i,int *pass)
{
for(int j=1,b=5;j<7;j++,b--)
{
pass[b] = ( (i%(int)pow(10,j) - i%(int) pow(10,(j-1)) )/(int) pow(10,j-1) );
}
}
int main(void)
{
FILE *file = fopen("crp.txt","r");
if(file == NULL)
{
printf("File not found");
return 1;
}
fseek(file, 0, SEEK_END);
unsigned long int len = ftell(file);
rewind(file);
int dataset[len/600][10][10];
for(int i=0;i<len/100;i++)
{
for(int j=0;j<10;j++)
{
for(int k=0;k<10;k++)
{
fscanf(file,"%6d",&dataset[i][j][k]);
}
}
}
dict example[64];
for(int i=0;i<63;i++)//Yerleştirildi türkçe karakterler eklenmeli
{
example[i].character = (65+i);
example[i].pass = (65+i+50);
}
example[63].character = ' ';
example[63].pass = 300;
int key;
int key_array[6];
printf("Enter Key: ");
scanf("%d",&key);
extract(key,&key_array);
int en_text[6];
extract(dataset[key_array[0]][key_array[1]][key_array[2]],&en_text);
int counter =0;
for(int j=0; j<=1 ;j++)
{
for(int i=0;i<64;i++)
{
if(example[i].pass == (en_text[3]*100 + en_text[4]*10 + en_text[5]))
{
printf("%c",example[i].character);
break;
}
}
if(en_text[0]*100 + en_text[1]*10 + en_text[2] == key_array[3]*100 + key_array[4]*10 + key_array[5])
{
counter = 1;
}
if(counter == 0)
{
j--;
}
extract(dataset[en_text[0]][en_text[1]][en_text[2]],&en_text);
if(en_text[3]*100 + en_text[4]*10 + en_text[5] == 0)
{
printf("\nWrong Pointer\n");
return 3;
}
}
}