Commit | Line | Data |
---|---|---|
8de51304 H |
1 | #include <stdio.h>\r |
2 | #include <stdlib.h>\r | |
3 | \r | |
4 | int main(int argc, char *argv[])\r | |
5 | {\r | |
6 | int k, i; //Key, In,\r | |
7 | //char sfkey[128] sfin[128], sfout[128];\r | |
8 | if (argc <= 1 || argc > 4 ) { printf("Usage: crypt key [in] [out]\n"); return 1; }\r | |
9 | FILE* fkey = fopen(argv[1], "rb"); //Open Key\r | |
10 | if (argc >= 3) { freopen(argv[2], "rb", stdin); } //Reopen stdin\r | |
11 | if (argc == 4) { freopen(argv[3], "wb", stdout); } //Reopen stdout\r | |
12 | \r | |
13 | while( (i = getchar()) != EOF ) {\r | |
14 | if ( (k = getc(fkey)) == EOF )\r | |
15 | { fseek(fkey, 0L, SEEK_SET); k = getc(fkey); }\r | |
16 | //printf("%d: %c\n", k, k); sleep(1); //Debug\r | |
17 | putchar(i^k);\r | |
18 | }\r | |
19 | return 0;\r | |
20 | }\r |