An alternative to encryption for game files?

This is a discussion on An alternative to encryption for game files? within the A Brief History of Cprogramming.com forums, part of the Community Boards category; Ok, I am not really sure how to encrypt and decrypt files so would a fair alternative be to give ...

  1. #1
    Registered User blackwyvern's Avatar
    Join Date
    Jan 2002
    Posts
    60

    An alternative to encryption for game files?

    Ok, I am not really sure how to encrypt and decrypt files so would a fair alternative be to give a range of items keys and if the values and keys dont match up then the file will be read corrupt by the game module?
    say like this:
    if (goldpieces < 50)
    {
    goldkey = 123476;
    };
    if ((goldpieces > 50) && (goldpieces < 100)
    {
    goldkey = 1567830;
    };

    or something like that?
    have all the keys follow the variables that they are supposed to error check for and if they dont match the file is unloadable. I know if they had the source file this would be no good, but if I released just the exe file then I believe it would work. Should I just learn how to encrypt files instead?

  2. #2
    B26354 Deckard's Avatar
    Join Date
    Jan 2002
    Posts
    633
    Still some room for tampering, I suspect. Consider using a CRC to safeguard your data (www.google.com).
    Jason Deckard

  3. #3
    B26354 Deckard's Avatar
    Join Date
    Jan 2002
    Posts
    633
    Here's a quick example:
    Code:
    #define CRC_MAGIC_NUMBER 0x1021
    
    unsigned short Crc16( char* psBuf, int nBufLen )
    {
      unsigned short usCrc = 0;
      int            nIdx, nJdx;
    
      for(nIdx = 0; nIdx < nBufLen; ++nIdx)
      {
        usCrc ^= (psBuf[nIdx] << 8);
        for(nJdx = 8; nJdx; --nJdx)
        {
          usCrc = (usCrc & 0x8000) ? (usCrc + usCrc) ^ CRC_MAGIC_NUMBER : (usCrc + usCrc);
        }
      }
    
       return( usCrc );
    }
    Jason Deckard

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Reading .dat files from a folder in current directory...
    By porsche911nfs in forum C++ Programming
    Replies: 7
    Last Post: 04-04-2009, 10:52 PM
  2. Working with muliple source files
    By Swarvy in forum C++ Programming
    Replies: 1
    Last Post: 10-02-2008, 09:36 AM
  3. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM
  4. Folding@Home Cboard team?
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 398
    Last Post: 10-11-2005, 09:44 AM
  5. Batch file programming
    By year2038bug in forum Tech Board
    Replies: 10
    Last Post: 09-05-2005, 04:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21