3

I'm working on a text based adventure game in C++ and I would like to store quests in a text file,but I don't want the player to read it.

Is there an easy way to encrypt it?

WarrenT
  • 4,502
  • 19
  • 27
Haewen
  • 33
  • 3
  • 2
    Do you want to encode it or hide it? Quite different things. – john Nov 13 '13 at 15:47
  • Unless you are writing in C++ *and* the [RPG language](http://pic.dhe.ibm.com/infocenter/iseries/v7r1m0/topic/rzahg/rzahgrpgcode.htm) you should not use the [tag:RPG] tag. Please read what a tag means on this site before using it, and the definition pops up making it dead simple. – WarrenT Nov 13 '13 at 17:32

2 Answers2

1

Another way to "hide" content of your file to player is to encrypt the file.

You can use openssl for instance.

In this thread you can have an idea on the usage.

Community
  • 1
  • 1
Luca Davanzo
  • 21,000
  • 15
  • 120
  • 146
0

Velthune's OpenSSL suggestion is fine but it is arguably overkill. I would try something simple like XOR encryption instead.

Of course XOR encryption is not secure, but neither is the OpenSSL approach, since your program must store the encryption key somewhere in the executable file in order to be able to do the decryption.

There is no way to truly secure the file's contents against a determined user and still have it be accessible to a program that runs on the user's machine.

So, I'd suggest XOR encryption as a simple form of obfuscation that will deter someone from changing the file casually, yet won't make your program dependent on an external library.

Community
  • 1
  • 1
antinome
  • 3,408
  • 28
  • 26
  • To put it another way: you don't need a top-of-the-line lock on your front door if you're going to be leaving the key under the mat. A cheap look is probably good enough. :-) – antinome Nov 13 '13 at 18:12
  • And here's a simple program to do that for you on windows , it comes with source code so you can build it for your platform https://sourceforge.net/projects/xorencrypt2/ – Namit Sinha Jun 25 '14 at 10:44