Latest Computer Forum Topics:

  • Nintendo "Hand-Held" ? (8 posts)
  • my laptop has no firewire input :{?? (5 posts)
  • Does slow computer mean I need new motherboard??? (7 posts)
  • PCIe x16 2.0?? (5 posts)
  • TDU Problems?? (2 posts)
  • Anyone heard of MS Office Ultimate 2007 for ??!!? (5 posts)
  • Windows Defender??? (3 posts)
  • working with adobe files??? (5 posts)
  • Viewing thumbnails on a website??? (2 posts)
  • Dreamweaver or Fireworks??? (2 posts)
  • what all needs to be completed in Kingdom Hearts for there to be the music video at the end? (3 posts)
  • Air Mouse??? (3 posts)
  • Ramdac?????????? (2 posts)
  • Broadband problem with XP?? (5 posts)
  • HDMI Monitor?? (3 posts)
  •  
    Author Message

    SecretHoarder

    Members


    Online status

    514 posts

    Location: Guam
    Occupation: Market gardener
    Age:

    #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

    Members


    Online status

    486 posts

    Location: Malawi
    Occupation: Lobbyist
    Age:

    #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 <