Hello, I made a game and I plan to sell this game with its source codes. However, I want to encrypt a file or script in my game. Is this possible?
Not truly encrypted. So that a game runs on the computer it needs to be decrypted. So you’d have to send the encryption key alongside it which renders that aproach pointless.
Instead there is a form of inherent one-way encryption through compilation which turns C# into machine specific code. It’s possible to compile C# to a Dll and then use it externally.
Note that this complicates distribution for different platforms and due to the fact that all your game content has to be processed by the hardware, there unfortunately always are loopholes (hope you are not considering to store precious information like server access data in that file).
If it’s just to prevent most people from “stealing your code”, that is enough.
If it’s about some kind of access token or account login information that’s personalized to you, you must wipe that data and make sure in the instructions that users understand that and how to set up their own token/account. Code should check for unset token/login data to inform users who don’t RTFM.
Put it on the server.
You can not protect any files from being viewed, decompiled, unencrypted, once they land on local machine.
Specially if your application need to read it anyway.
You may make it harder to some, but someone eventually crack it anyway.
You will spend amount of time and resources, to make a encryption feature, which become soon obsolete, as someone will decrypt them and possibly make such assets public. Not worth an effort.
It’s not possible. You have to give an executable to an untrusted client.
Always assume that the kind of person who wants to steal your code or cheat at your game has the equipment to make it trivial to do so. They have Administrator/root. They have debuggers that can stop processes. They have memory chip dumping hardware. They have code analysis tools that will give them all your subroutines, albeit with funny names for variables. They have time and patience and bosses who want to clone your game because it’s cheaper and more certain than making their own.
You may trust the company you’re selling this game to honor a contract that says the DLL is to be used as-is and remains your intellectual property. That’s all on the honor system with legal documentation as your only real protection.
Yes, but it’s always a temporary measure and never a permanent solution. You can obfuscate source code which will rearrange the code, rename the methods and variables, and so on, but having had to work with obfuscated code in the past let me assure you it’s not hard for someone to change the code or extract information.
File encryption is just a temporary measure too because at some point the data has to be decrypted in order for the hardware to be able to use it. Extracting information straight out of system and video memory is a trivial task with tools that you can download straight off of Github to do the work.
Thank you for your answers. I guess I won’t bother with encryption. Instead, it makes more sense to contract. @Ryiah @halley1 @Antypodish @CodeSmile @DragonCoder .