-
Notifications
You must be signed in to change notification settings - Fork 0
/
coder.c
68 lines (49 loc) · 1.57 KB
/
coder.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
/********************************************************
Encryption/decryption program v1.0
by Satya <http://satyaonline.cjb.net>
Compile: `gcc coder.c -o coder`. Probably platform independant, only
tested on Linux RedHat 6.0.
Use at own risk. Freeware. Please keep these comments intact. Inform me of
changes and redistribution. Give me credit if used anywhere. Standard
disclaimers apply.
This method is not secure! Do not use for encrypting sensitive material!
Remember the passwords, if you forget a password I know no way of
recovering original file!
Takes two arguments: input file, and output file. Output file will be
clobbered if it exists. Will ask for password of maximum length KEYLEN
characters (letters (case sensitive), numbers, some special characters).
Stick with letters and numbers.
********************************************************/
#include <stdio.h>
#define KEYLEN 20
int main(int argc, char *argv[]) {
char ch;
int i=1;
char pass[KEYLEN];
FILE *in,*out;
if (argc<3) {
fprintf(stderr,"usage:\n\t%s input_file output_file\n",argv[0]);
exit(1);
}
if ( (in=fopen(argv[1],"rb")) == NULL ) {
fprintf(stderr,"%s: failed to open %s\n",argv[0],argv[1]);
exit(2);
}
if ( (out=fopen(argv[2],"wb")) == NULL ) {
fprintf(stderr,"%s: failed to open %s\n",argv[0],argv[2]);
exit(2);
}
printf("Enter password (upto %d characters, no spaces):",KEYLEN);
for (i=0;(pass[i]=getchar())!='\n' && i<KEYLEN;i++);
i=1;
while (fscanf(in,"%c",&ch)!=EOF) {
ch=pass[i] ^ (~(ch));
i++;
if (i>strlen(pass)) i=1;
fprintf(out,"%c",ch);
}
fclose(in);
fclose(out);
return 0;
}
/*EOF*/