hello again...
just wondered if you would check this code for me and give me some pointers.. (maybe i could improve it).
it's a XOR encryption code.. , the only problem is that it is quite slow....
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <io.h>
#include <conio.h>
void ****it()
{
printf("can't write to file");
getch();
exit(1);
}
void main()
{
FILE *in,*out;
char ch,key[100],fname[100],fname2[100];
int i,s,len=0;
float f,count=0;
clrscr();
printf("enter source file: ");
gets(fname);
if(access(fname,0))
{
printf("no file by that name");
getch();
exit(1);
}
printf("enter target file: ");
gets(fname2);
printf("enter key: ");
gets(key);
len=strlen(key);
if((out=fopen(fname2,"wb"))==NULL) ****it();
if((in=fopen(fname,"rb"))==NULL) ****it();
fseek(in,SEEK_SET,0);
for(f=0;!(feof(in));f++)
fgetc(in);
fseek(in,SEEK_SET,0);
i=0;
printf("processing please wait... ");
printf("\npress any key to stop\n");
while((!(feof(in)))&&(!kbhit()))
{
_setcursortype(_NOCURSOR);
ch=fgetc(in);
count++;
cprintf("%8.0f precent done\r",(count/f)*100);
if(i>len-1) i=0;
ch=ch^key[i];
fputc(ch,out);
i++;
}
if(feof(in)) cprintf("\ncomplete");
else cprintf("\n processing has been stoped - fail to complete");
fclose(in);
fclose(out);
getch();
exit(1);
}