- Home /
How to create a secure package?
Hi...
I have created one package from some of my prefabs in my project. these prefabs have some C# codes in them and what i want is to encrypt these codes like no one can see the actual codes!!
I've seen some packages that use ".dll" files and in their code files they just use their own methods. i wanted to build a dll file from my code like what it said in this link
http://www.c-sharpcorner.com/article/creating-C-Sharp-class-library-dll-using-visual-studio-net/
but i couldn't get any dll file!
What should i do?!!
Answer by Jam0kid · Sep 11, 2017 at 05:01 AM
Creating a dynamic linked library requires you to first need something to turn into a .DLL file. The main idea of a .DLL is that it is either imported or embedded at compile/runtime, after which scripts in your game reference code under it's namespace.
For example, let's say we have a math library in which it contains a class for a vector and some basic functions.
So you'd first make sure your project is set to build as a .DLL in visual studio, then go ahead and compile it (F7) to your builds folder.
Of course, it's all up to speculation how you have it set up, but once it's exported to this file, it'll allow you to import it into unity (If it's C#, or a version of C++ that allows you to import it.)
So now in our C# code we can call "using VectorNamespace;" then use everything from that file we made.
But then, I imagine that if you wanted to just drag and drop a .DLL onto a prefab, you might suffer some significant issues like it just not working. Perhaps look into a scripting language if you want to port at runtime, but I highly suggest just rolling without encryption until you need to release your application or game based on the sole fact you would need someone there to show you, or google-foo to help you step by step.
Summary:
Create a new visual studio project, set it to 'Class Library' (.DLL export format)
Create a class under your new namespace, give it all you would in a generic script. You can import unity by using some magic; google it.
Build your solution using F7 or by going to Build/Solution in your toolbar.
Locate the exported DLL if it succeeded to build.
Import to unity under a new folder called Plugins under Assets ("Assets/Plugins/(your dll)")
Reference your code in the .DLL.
Best of luck to you! If something is vague or you need someone to help you out with your google-foo, don't hesitate to send me a P$$anonymous$$ with more questions.
This worked very nice... does this way create a high security dll or i should use Encryption and Decryption to make it.
Overall, a .DLL can only get you so far unless you roll your own encryption method, or want to import some sort of wrapper to make sure everything is 'safe'. But realistically, if people want to dig, they can and will find a way to do it. A .DLL keeps out the idiots, and they are the majority of people that want to get into your files. $$anonymous$$y suggestion is to encrypt only sensitive data and have a remote decryption tool that requires specific keyphrases to handle, however this is overkill.
By the way, anyone can get a DLL content viewer and see your function declarations anyway. It's a whole other matter of decompiling it and getting your code, though.