forked from keertheerajan/stegnography
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdecode_data.c
More file actions
49 lines (39 loc) · 812 Bytes
/
Copy pathdecode_data.c
File metadata and controls
49 lines (39 loc) · 812 Bytes
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
#include<stdio.h>
#include<stdlib.h>
char *decode_data(const char *scr_file, int size)
{
static int byte_count=54;
unsigned char magic_char = 0,value;
FILE *fscr;
fscr = fopen(scr_file,"r");
if (fscr == NULL)
{
perror("fopen");
fprintf(stderr, "ERROR: Unable to open file %s\n", scr_file);
exit(1);
}
fseek(fscr,byte_count,SEEK_SET);
char *str = (char *)calloc(size,sizeof(char));
for(int i = 0,pos; i < size; i++)
{
magic_char = 0;
pos = 7;
//fread(&value,sizeof(char),1,fscr);
for(int j = 0; j < 8; j++)
{
fread(&value,sizeof(char),1,fscr);
byte_count++;
if(value & 1)
{
magic_char = magic_char | (1<<pos);
pos--;
}
else
{
pos--;
}
}
str[i] = magic_char;
}
return str;
}