forked from keertheerajan/stegnography
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecode.c
More file actions
88 lines (73 loc) · 1.76 KB
/
Copy pathdecode.c
File metadata and controls
88 lines (73 loc) · 1.76 KB
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
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
//static int byte_count = 54;
char *decode_data(const char *scr_file,int size);
int decode(const char *scr_file, const char *des_file)
{
FILE *fscr,*fdes;
char *return_str;
char password_size[2]={0,};
char password[5]={0,},ch;
int size,file_size;
fscr = fopen(scr_file,"r");
if (fscr == NULL)
{
perror("fopen");
fprintf(stderr, "ERROR: Unable to open file %s\n", scr_file);
exit(1);
}
fdes = fopen(des_file,"w");
if (fdes == NULL)
{
perror("fopen");
fprintf(stderr, "ERROR: Unable to open file %s\n", des_file);
exit(1);
}
return_str = decode_data(scr_file,2);
printf("%s",return_str);
if( !strcmp(return_str, "#*") )
{
printf("INFO : MAGIC STRING IS PRESENT\n");
printf("ENTER THE SIZE OF PASSWORD: \n");
fgets(password_size,2,stdin);
getchar();
printf("ENTER THE PASSWORD: \n");
size = atoi(password_size);
fgets(password,size+1,stdin);
return_str = decode_data(scr_file,1);
if( !strcmp(password_size,return_str) )
{
free(return_str);
return_str = decode_data(scr_file,5);
if( !strcmp(return_str, password) )
{
free(return_str);
return_str = decode_data(scr_file,1);
file_size = atoi(return_str);
free(return_str);
printf("INFO: PASSWORD MATCHED\nDECODING STARTED .....\n");
return_str = decode_data(scr_file,file_size);
for(int i=0;i<file_size;i++)
{
ch = return_str[i] ;
fwrite(&ch,sizeof(char),1,fdes);
}
free(return_str);
}
else
{
printf("INFO: INVALID PASSWORD\n");
}
}
else
{
printf("INFO: ERROR: INCORRECT PASSWORD\n");
}
}
else
{
printf("INFO: NOTHING IS HIDDEN TO BE ENCODED\n");
}
return 0;
}