Forums / Public / Programming & Design / Just finished my c++ encryption program. Anyone want to check my code?
| Author | Message |
SecretHoarder
514 posts |
#186246 2008-02-28 22:53 GMT |
|
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 |
|
LollypopLover
486 posts |
#186247 2008-02-29 04:10 GMT |
|
(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. |
|
> 1 <
tools picture malicious audio pointing deleted foster shoulder litepipes adults gaming inkje boards produces education sever first charge disks running inches green universal batch foreign metal prevent common n check names blad files creative or authorized checks kind text controller online identities levels parenting modern friends sights computers audi records
Categories: IT CD Duplication Video Game Testing Text To Speech Adware & Spyware Nintendo Wii Computers Web Conferencing Identity Carpal Tunnel Operating Systems Playstation 3 Technical Analysis Data Recovery Broadband Computer Games Internet Safety CD Duplication Satellite Radio PC Security Voice Over IP Healthy Computing The Nintendo Wii Identity Theft Bluetooth Data Recovery Projectors Printers Fiber Optics Better Health for Computer Users Broadband



