0
\$\begingroup\$

I have some game data files in PDF, excel, and video format. Is there any way to make it secure? Through encryption? I have almost encrypted my all files in .aes encryption format but there is a huge problem i have to decrypt it each time when i have to show it to the user ! Therefore I have to place it inside file explorer and anyone can access it. How do I prevent it?

\$\endgroup\$
6
  • 2
    \$\begingroup\$ If the data is in the hand of the user, he can access it. You can only make it harder for him but not prevent it totally. \$\endgroup\$
    – Zibelas
    Apr 27, 2022 at 10:03
  • \$\begingroup\$ yes, exactly I want to make it harder for him to decrypt at least. \$\endgroup\$ Apr 27, 2022 at 10:16
  • \$\begingroup\$ For 99% of the users, it is probably enough if you just encode/ save your data as a byte stream. It is not a true encryption but makes it not possible to read/ write the file by a normal file browser. But what are you in the end trying to prevent? That the user is changing data (for different gameplay/ cheat), that he can access it at all or something else? \$\endgroup\$
    – Zibelas
    Apr 27, 2022 at 10:19
  • \$\begingroup\$ There is one excel file where he create users/roles. While there are some other excel files contains some data open in excel, or some pdf and video files. \$\endgroup\$ Apr 27, 2022 at 10:26
  • 1
    \$\begingroup\$ You may be interested in Is it worth it to encrypt data? \$\endgroup\$
    – DMGregory
    Apr 27, 2022 at 12:18

1 Answer 1

2
\$\begingroup\$

First things first: if the data is in the user's hands (stored on their device or even just displayed), they have access to it and it should be treated as such. That means regardless of what kind of encryption you employ, if they spent enough time, they can / will always be able to get it. All you can do is make it harder for them.

Now you noticed it yourself already that encrypting is already a performance issue for you. But is that really needed? Since we know that if they really want that they can get the data, we actually just need to prevent first 99% of the users to casually read the data. Storing it in a format that is easy to read (for your application) but hard for the user (file manager) is rather trivial. Instead of saving it as a common type (like .xsl, .xml, .pdf) just store it as a byte stream.

Now the harder part: what are you trying to prevent? In case you want to prevent manipulation of fixed assets (like values for stats, scores, saves), in addition to storing the file you can store a hash. On load you compare the hash of it to the file (you would rehash the file) to make sure they are equal. This does not prevent manipulation totally since if the hash is local, it can be manipulated as well. Just another layer of making it harder.

If you want to prevent theft of assets, this is even harder. The easiest way would be probably to not use any common format but have a custom developed one. If you are the only one that uses the format, it reduces the chance that others are willing to spent the effort trying to find out how to use them. Again just making it harder.

If you want to prevent the loss of sensitive data, do not store it locally at all. Keep it on your own server to make a data mining of it harder.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ A couple of notes here: deterring casual users from reverse engineering your data themselves doesn't deter that single dedicated hacker from doing it and releasing a one-click cracking application that automates it. So now even your most casual users can access and modify any data the most dedicated hacker can. The only way to fully protect game data from being modified to cheat is with an authoritative server. Also, a common way to rip visual assets from a game is to intercept rendering calls at the driver level, so no amount of obfuscation of the stored data on disc will deter that. \$\endgroup\$
    – DMGregory
    Apr 27, 2022 at 12:58
  • \$\begingroup\$ if i store it in byte stream then how to show it within excel or pdf viewer? I definitely need to convert it and then need to store on the hard drive of the user? \$\endgroup\$ Apr 28, 2022 at 5:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .