-
Notifications
You must be signed in to change notification settings - Fork 2
/
encode.c
65 lines (49 loc) · 1.14 KB
/
encode.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
#include <stdio.h>
#include <string.h>
#define MAX_FILE_SIZE (1024*1024*4)
int main( int argc, char *argv[] ) {
unsigned char argv_int[44];
char final_name[100] = "secured_";
if( argc == 3 ) {
FILE *fptr;
unsigned char* data = (char*)malloc(MAX_FILE_SIZE);
int y = 0;
while(argv[2][y]){
if(y == 44)
break;
argv_int[y] = argv[2][y++];
}
fptr = fopen(argv[1], "rb");
int i = 0;
while (!feof(fptr)) {
data[i++] = fgetc(fptr);
}
fclose(fptr);
fptr = fopen(strcat(final_name, argv[1]), "wb");
int j;
for(j=0 ; j<i-1 ; j++){
if(j>=880 && j<924){
if(j == 880)
fputc((data[j] ^ argv_int[j-779]), fptr);
else if (argv_int[j-880])
fputc((data[j] ^ argv_int[j-880]), fptr);
else
fputc((data[j]),fptr);
}
else
fputc((data[j]),fptr);
}
fclose(fptr);
printf("Key Secured Successfully\n\n");
printf("Your Message: ");
int z = 1;
while(argv_int[z])
printf("%c", argv_int[z++]);
printf("\nNew Image Name: %s\n", final_name);
}
else if( argc > 3 )
printf("Too many arguments supplied.\n");
else
printf("Two argument expected.\n");
return 0;
}