Large amounts of hidden data

Hello,

I want to write console application. To be more precise, it will be "Who wants to be a millionaire" game.
It is just for fun, nothing else.
So, I need to have this hmm, lets say database of all those questions, and correct answers.
Now, what is the best way of storing this data, so that user can't read it, and also important thing is portability.
If I would have to install MySQL server, that is bad idea,
because I don't know if my friend, who wants to play this, has it on his computer.

I think you got the point. Thank you :D
The easiest way is to just use some simple xor encryption.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
void Transform(string& s)
{
  static const char key = 0xB6;

  for(unsigned i = 0; i < s.size(); ++i)
    s[i] ^= key;
}


int main()
{
  string data = "This is your questions and answers";

  // to save it to a file
  Transform(data);
  WriteDataToFile(data);


  // to get it from a file
  data = ReadDataFromFile();
  Transform(data);

  cout << data;
}



Not very secure, but it will be enough to stop most non-techie people from cheating, and it's very simple.
Last edited on
and I should save this encrypted data in plain text file?
That would work, yeah. Although I wouldn't give it a .txt extension.
and, I'm just wondering, why is key in hex form?
That just make it easier for me to pick a suitable one. I figured it would be best to flip some bits but not all, and to avoid having a null terminator in the encrypted string.

So I came up with 10110110 which is 0xB6
Topic archived. No new replies allowed.