CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Thread: Caesar cipher

Threaded View

  1. #1
    Join Date
    Oct 2008
    Posts
    4

    Question Caesar cipher

    Hi everyone
    I have been trying to create a simple encryption program it will read the txt from a .txt and then if plaintext encrypt it or if encrypted decrypt it to plaintext using the caesar's cipher I just can't get my head around as I am only new to c++ programming

    Any help or ideas would be great

    Here's what I have so far:

    Code:
    #include <iostream>//for input and output
    #include <fstream>// for working with files
    
    #define isupper(a) ((a)>= 'A' && (a)<= 'Z') 
    #define islower(a) ((a)>= 'a' && (a)<= 'z') 
    
    using namespace std;
    ifstream inFile;
    ofstream outFile;
    char PlainText[100], CipherText[100] ;
    int main() 
    {
        {
           outFile.open("test.txt");
           (!outFile.eof() << PlainText[100]);
           for ( int i = 0 ; PlainText[i] ; i++ )
           {
               if ( isupper(PlainText[i]) )
                CipherText[i] = 25 - (PlainText[i] - 'A') + 'A' ;
               else if ( islower(PlainText[i]) )
                CipherText[i] = 25 - (PlainText[i] - 'a') + 'a' ;
               else CipherText[i] = PlainText[i] ;
            }
           outFile << CipherText << endl;
        }
    inFile.close();
    system("pause");
    return 0;
    }
    Thanks in advance
    Last edited by hitman_38; October 27th, 2008 at 10:40 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured