It’s not safe by default. You could implement a file hook, which encrypts the complete file content or, as @milos1290 was suggesting, encrypt the values.
You don’t need to even use SQLite. The easiest way is to store your save game data in a binary blob and apply your hashing methods.
Encryption does not prohibit your data much from hacking. It only makes editing values harder. If you safe your values as binary data, an attacker could change your values and hope they will make sense. The data would just create random values or even generate overflows.
What you should look into is hashing your content/values with some cryptographic hash function like the sha-2 family. For your purpose xxhash would even suffice, but keep in mind, that it’s non-cryptographic.
Hashing your content will prohibit tempering with your data. You need to combine two or more hashes to generate a secure hash. E.g. hash of some system file + hash of your content/value. Keep this method secure as possible!
Hashing of the value/content alone won’t make it secure, as the attacker could guess easily, which content you hashed.
The problem with encryption is, that you have to store your key in some place, even in memory. As long as you can’t store it in a secure place like in-hardware(which could also be cracked) and your client is not safe, an attacker can get your key and it will render your encryption useless. If an attacker is able to get your encryption keys, it’s also very probable, that he can Reverse Engineer your hashing methods.
If your client is broken(which is the case with consoles, PC, mobiles,…), it’s game over. The only thing you can do is make it harder for an attacker, but not prevent it.
This would not prevent an attacker from hacking, as he can still manipulate the data sent to the server, where it will get stored.
I agree with you, that such users would just be the minority, but don’t forget, that you can also run Android in a VM on your PC and there are also software stacks for running your mobile games on the PC.
Just apply some hashing. You could also apply encryption to make it harder to edit your content.
You can’t, unless you have a safe place to store it, which does not exist for your target devices. The time you safe the key on a broken client, you can’t do something against it. It’s just a weighing up of what’s in there for an attacker to crack your game.
It will create random data with some possibility of creating a valid number or an overflow, which will crash your game.
If you really want to prevent cheating, you would need to implement and analyse game play statistics like the FairFight system is doing:
It would only learn him to apply “rinse and repeat”. He would just need a backup of his save-game and he can just repeat it.
If an attacker is eager to hack, I guess he maybe would not care about resetting it’s stats.
Obviously some time-intensive hobby ![]()
