How do I encode .json files

Get help using Construct 2

Post » Sun Sep 25, 2016 4:18 am

Hi all, I'm approaching a project and deciding how to set up my levels. I've decided I want to have a level editor, and if I made it good enough it would be the easiest way make official levels for the game. My problem with this though, is that I would have to create the levels with the editor than import them at runtime, and to do that I have to include that level data in .json project files. This game will probably also have a multiplayer mode that may be influenced by single player progress, and I don't want achievements to be easily hacked. By including the .json files for each level, players can easily modify level data and cheat, so is there a way to encode these files and decode them on C2 import, or another solution to this issue? Thanks.
B
72
S
24
G
11
Posts: 452
Reputation: 12,387

Post » Sun Sep 25, 2016 7:53 am

Regardless of whether you encode the level data or not, the triggers for achievements will be able to be modified, if your server side app blindly trusts what the client reports.

Disclaimers aside, you could use the CBHash plugin to do this - https://www.scirra.com/forum/plugin-cb-hash-md5-sha-1-and-sha-256_t62215
B
9
S
1
Posts: 12
Reputation: 448

Post » Mon Sep 26, 2016 6:10 pm

paladin wrote:Regardless of whether you encode the level data or not, the triggers for achievements will be able to be modified, if your server side app blindly trusts what the client reports.

Disclaimers aside, you could use the CBHash plugin to do this - https://www.scirra.com/forum/plugin-cb-hash-md5-sha-1-and-sha-256_t62215


Well achievements are handled by steam, but again it's more an issue of multiplayer balancing. I'll look into that plugin, thanks!
B
72
S
24
G
11
Posts: 452
Reputation: 12,387

Post » Wed Sep 28, 2016 3:42 pm

You should just have a server that dictates the JSON and secure your server.

The problem with hashing is that it is one-way, you cannot "decode" a hash.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,857

Post » Wed Sep 28, 2016 5:15 pm

gumshoe2029 wrote:You should just have a server that dictates the JSON and secure your server.

The problem with hashing is that it is one-way, you cannot "decode" a hash.


That would require the player to be online though to play the game at all, which isn't ideal. And it would end up being saved somewhere would it not, just harder to find.
B
72
S
24
G
11
Posts: 452
Reputation: 12,387

Post » Wed Sep 28, 2016 5:42 pm

As far as I know, you'll need to write a bit of code or use a plugin to encrypt/decrypt your json when you save/load it. One of the simplest ways is a character shift/replacement. It can be cracked, but if you have the luxury of worrying about the tiny population that would go through the effort, you probably have a wildly successful game already anyways (And then you can just change the method if you REALLY care that much. Which you probably won't.)

Loading the files from a server is indeed the most secure method. At the very least, a user would not be able to change the file.

If you think any offline game can be safe from hacking, that is simply not true. Effort and time is best spent improving your game rather than worrying about hackers, or you will never get to the point where you make a game worth hacking to begin with.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Thu Sep 29, 2016 2:20 pm

ReflextionsDev wrote:
gumshoe2029 wrote:You should just have a server that dictates the JSON and secure your server.

The problem with hashing is that it is one-way, you cannot "decode" a hash.


That would require the player to be online though to play the game at all, which isn't ideal. And it would end up being saved somewhere would it not, just harder to find.


Not necessarily. You can just have the game ask the server on start for all of the JSON necessary to run the game. Then you would talk to the server once at start and never again after that.
https://www.ravenheart.ca/home
I don't check the forums much anymore, but I will receive an email for PMs.

"Someone once told me I bite off more than I can chew...

I told them I would rather choke on greatness than nibble on mediocrity."
B
23
S
6
G
1
Posts: 1,419
Reputation: 4,857


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 29 guests