C Encryption?? Adding Encryption To Text File?

Discussion in 'C' started by BillyBob, Dec 14, 2007.

  1. BillyBob

    BillyBob New Member

    Joined:
    Dec 14, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Hi I have this code to send a .txt file between 2 computers, I want to know how can I add simple encryption to it?
    Code:
    #include <stdio>
    #include <conio>
    
    #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);
    }
    I don't have a clue and please can someone give me an idea? also where where I stick the code, I'm still a noob.
     
    Last edited by a moderator: Dec 15, 2007
  2. Salem

    Salem New Member

    Joined:
    Nov 15, 2007
    Messages:
    133
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Please don't PM me for 1:1 support.
    Last edited: Dec 16, 2007
  3. BillyBob

    BillyBob New Member

    Joined:
    Dec 14, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    0
    Bunch of fags, get off your computers and step outside for a minute.
     
  4. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice