PDA

View Full Version : An alternative to encryption for game files?



blackwyvern
03-27-2002, 01:07 PM
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?

Deckard
03-27-2002, 01:19 PM
Still some room for tampering, I suspect. Consider using a CRC to safeguard your data (www.google.com).

Deckard
03-27-2002, 01:31 PM
Here's a quick example:


#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 );
}