Tuesday, July 14, 2009

C/C++ EXERTS? A little bit of help?? How would I encrypt/scramble a simple text file?

I am sending a text file and I want to just scramble it?





Here is my code?





#include %26lt;stdio.h%26gt;


#include %26lt;conio.h%26gt;





#define CNTRLZ 0x1A





char sourceFileName[] = "H:\\text.txt";


char commStreamName[] = "COM1";


FILE *commStream;


FILE *SouceFile;


char charToSend;


char ReadAccess[] = "r";


char WriteAccess[] = "w";


char errorMsg[] = "fail to open data file\n";


char fileopenflag[] = "r";


char EndOfFile[] = "EOF";





int main(void) {


FILE *fp;


FILE *dp;


int c;





if ((dp = fopen("COM1", "r")) == NULL) {


printf("fail to open COM port\n"); return 1;


}








if ((fp = fopen( sourceFileName, "w")) == NULL) {


printf("fail to open data file\n"); return 1;


}








while ((c = fgetc(fp )) != EOF) {


fputc( c, dp);


putch(c);





}





fputc('*', dp);


fclose(dp);


fclose(fp);


}





Where abouts would the code go and how would I define it?





Any examples please? I'm a noob.

C/C++ EXERTS? A little bit of help?? How would I encrypt/scramble a simple text file?
I wrote an XOR (the ^ character) that would encrypt/decrypt to a string. Sadly I just it, but use an XOR. If you use a long string, it can be very hard to decrypt without the key.


No comments:

Post a Comment