Page 1 of 1

Encrypting Files

Posted: Thu Aug 27, 2015 3:35 pm
by jchill95
So I've been working on an encryption algorithm to save my game files. My current approach is a double hash encryption: this is where you generate two keys and you get the hash values of both, then you multiply those together to get a master key and multiply that value by the bits of the data you want to encrypt to get the encrypted data.

My question is, what are some alternatives/ your favorite encryption algorithms to use for your save file data?

Re: Encrypting Files

Posted: Sat Aug 29, 2015 3:27 pm
by dandymcgee
I usually encrypt mine with ASCII. What can I say.. I like modders. 8-)

On a more serious note: If you're decrypting the data locally, it's not safe. If the encryption key is stored locally, it's a trivial matter to extract it and modify the game files manually. The only way to truly protect save data is to store it server-side (which obviously isn't an option for offline games). Because of this, I find it rather silly to even bother trying to protect it at all. Although, most modders do enjoy a good challenge now and again, so there's that.

Re: Encrypting Files

Posted: Mon Aug 31, 2015 5:19 pm
by jchill95
I'm currently using Unity, so all the keys are generated within the engine and stored in Unity's data format internally upon build. I like the idea of having modding, but for a simple mobile game I think it would be tacky for the user to be able to change their high score, currency value, etc by simply opening up a text file and changing values that are plain to read. I would say that its not as much of an encryption algorithm as it is a data scrambler. I'm also using it for my 2D toolkit. Idk if Unity is frowned upon, but I find it meets my team's needs right now. It just doesn't have all the tools and resources I feel it should already have. Like C# has encryption and compression libraries built in, but Unity stripped them of it, that is why I decided to write my own.

On another note, do you know a good way to make a data table for the ASCII values. That was my original plan to write the save file format in, but ASCII references were replaced with Unicode; so I would have to make my own table/ lookup algorithm.

Re: Encrypting Files

Posted: Tue Sep 01, 2015 3:25 pm
by dandymcgee
jchill95 wrote:I'm currently using Unity, so all the keys are generated within the engine and stored in Unity's data format internally upon build. I like the idea of having modding, but for a simple mobile game I think it would be tacky for the user to be able to change their high score, currency value, etc by simply opening up a text file and changing values that are plain to read.
Ah, mobile app. Completely different story there. I was thinking you were targeting PC users.
jchill95 wrote:On another note, do you know a good way to make a data table for the ASCII values. That was my original plan to write the save file format in, but ASCII references were replaced with Unicode; so I would have to make my own table/ lookup algorithm.
If the default is Unicode, I would be wary of using something else. There is probably a reason it's Unicode (usually related to foreign language compatibility). That said, if you're not storing any user-generated data (usernames, device names, passwords, etc.) and you're writing the save/load mechanisms from scratch, then you're free to encode the data however you wish. I would lean toward keeping it as simple as possible.