Sunday, October 22, 2017

c++ - How to hide assets from user? ( e.g.: a png file )


I think the title is quite self-explaining, still this is a big area I think, so let me drop a few words:


I've got a simple experiment game project going, and I want to make sure, that the user isn't messing with the game assets like player skin etc.


In my opinion the best way would be that on production I would merge all the assets into one file and the application would check the hash of that file, so it could detect the corrupted data.


Is this an acceptable practice? There must be sum libraries / applications which are targeting this problem, could you guide me on this?



Project details: unix/linux, c++, sdl



Answer



My answer to this question won't be complete, because there is no real good way to achieve what you want.


Assume you would pack all your assets in one zip file and compute the hashes. This leads to the problem that you need to recompile your project if you hardcode your expected hashes. However if you save the hash in another external location, you would need to protect that, too.


One method to protect your assets I often rely on is using PhysicsFS to pack my assets in different packed zip files. In order to protect them, you could use some kind of symmetric encryption to secure your archives. If you do not plan any AAA-game this should be fairly enough to protect everything. But keep in mind, too much encryption etc. won't be useful and eventually decrease performance if you load your assets on-the-fly.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...