Computer problems,Computer help
*AX SOFT>>>Programming & Design

Just finished my c++ encryption program. Anyone want to check my code?


The source code for my encryption program is too big to fit here so i uploaded it as a text file to a file hosting site. The link is below. Its not strong encryption but its enough to be unreadable to the eye. There are 5 "encryption keys" that it has to choose from. Each file contains 254 five digit numbers it the format:
46578
65448
94814
61167
etc, etc.
I generated the files using another program I wrote. If you want that file a link to it is below with link to the keys also in case you want to try the program.
What do you think of my code? How can I improve it? I used basically all of my c++ knownledge in this program, based on that what should I learn next?
Encryptor: http://www.mediafire.com/?qxyk94zx2xr
Key maker: http://www.mediafire.com/?wzzhnykelgm
Keys: http://www.mediafire.com/?z4nyuxmgfd0
http://www.mediafire.com/?yd2myvsf3mu
http://www.mediafire.com/?tzyyyxfwu2k
http://www.mediafire.com/?ww4ttkzmtpf
http://www.mediafire.com/?qefwd2t1zjx

Thanks

(1)

ifstream KeyRead;
KeyRead.open(EncrKey);
if(!KeyRead.is_open())
{
cerr << "File failed to open for read. Program ending." << endl;
system("pause");
return 1;
};

A file can be open but still in a failed state. You should read up on failbit, eofbit, etc. A common way to check for a properly opened file would be more like

if(! KeyRead) because operator! () will return true if failbit or badbit are set.

(2)
char OutFile[15] = "Messagex.encr";
....
FileTestTries++;
OutFile[7] = FileTestTries+48;

This is goofy. Take the time to write a real (and genuinely useful) function that appends numbers properly to the end of a filename string. Using std::string this is brain dead simple and then just us string.c_str() if you need to dump to char* strings.

(3) int FileTestLoop - use bool with true/false.

(4) ofstream Write, KeyRead; -- *really* bad variable names. Outfile, ofile, something like that. You can easily be using a library some day that has some function named Write(). Not a show stopper but get in good habits now.

(5) for(int z=0; z<UserInCount; z++)

Minor but ++z is slightly faster so try to get into the habit of using it in loops like this.

It's late and I can't read any more but in general it looks like a good effort. Keep going and keep learning. You are off to a good start.

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • Can a slideshow made in a vista work in a mac?

    The issue isn't actually whether the computer is running Windows XP, Vista or Mac OS X, but whether or not it has PowerPoint (or some compatible equivalent, like iWork or OpenOffice.org) insta...

  • Java Nested For Loops question?!?!?

    Here's my solution, it must have taken me 2 or 3 hours. This is a tough one, I think. When my mind got boggled with nested loops and complex logic, I broke things apart into separate methods...

  • What is the most popular C++ compiler and linker used in the programming industry today?

    Well, the compiler that industries use is of cause Visual Studio from Microsoft. Microsoft offers free Express edition for personal and student use.

    ...
  • Do companies still uses Visual Basic 6.0?

    A lot of companies still used VB6 because of the legacy issues. New windows like Vista still support VB6. For more info on VB6, visit my free tutorial site at ...

  • Where can I get a Turbo C?

    Download it from below link ...

  • Qbasic Character Help?

    Wow! QBasic... haven't used that in ages. I believe the code would be "chr(191)" to convert the ASCII code into a character. if that's not it, try Chr$(191)...

    ...
  • What u say about it ?

    It is very cool. The colour is nice. You should add a few pictures of the place you describe to improve the web site.

    ...
  • I'm learning C++?

    you make what ever you heart desires.. calculators.. math programs.. operating systems,.. videogames... text editors.. accounting software.. etc.. (your problem with the split second viewing is...

  •  

    Categories--Copyright/IP Policy--Contact Webmaster