Game Development Community

ASCII Converter or Encryption

by Katrina Rose · in Torque Game Engine · 10/14/2004 (4:45 am) · 2 replies

Hi,

Is there a string to ASCII converter in the C++ code that can be called from script? I am making popup questions that come up when you collide with a computer in our game, and I was going to put the questions in a text file. The problem would be that anyone would be able to open the text file and see the answers. I could offset the ASCII values and save them to a file that would make them look like jibberish to anyone lookinf at them. A better solution would be to encrypt the file and decrypt the file during the reading process, but I have no idea how to do that. Any help would be greatly apreciated.

Marrion Cox

#1
10/14/2004 (5:37 am)
I think there are several options:

1. You could hardcode the questions. (usually not recommended)

2. Put the questions in a stringtable resource that gets piled into your exe.

3. Put the questions in a database and use ODBC. (might be good if you have lots of questions, categories, etc)

4. Obfusicate, hide questions in the headers of jpg files, or simply give the file a different extension.

5. Weak encryption... simply jumbling the letters using a simple formula.

6. Strong encryption, using third party crypt libraries. This may eat up a few CPU cycles.

7. Just stick to the simple text file, knowing that if somebody really wants to know the answer that badly, they'll just go to the www to look for cheats.
#2
10/14/2004 (8:37 am)
I would go with option 5 there.

It sounds like you're trying to prevent the casual cheater.

After all, as a last resort, the serious cheaters will simply learn what the answers are and share them, as Eugene points out.

Just XOR the letters with 0x73 or any other number and save them as binary.

eg

// code to "encrypt" and "decrypt" a file
// call it once to encrypt, call it again to decrypt.
void XorTheFile(FILE* fpIn, FILE* fpOut, char XorCode)
{
  char c;
  while (!feof(fpIn))
  {
     c = fgetc(fpIn);
     c ^= XorCode;
     fputc(c, fpOut);
  }
}

.. i've never tried running that kind of thing where fpIn == fpOut. does that work ?