I want to have a referenced dll in my Windows Forms Application project. It is imperative to me that the dll is encrypted at first, and later decrypted on runtime when it needs to be used.
Please consider the following example where a sub routine is originally encrypted, but then decrypted and instantiated. Note, this is a conceptual idea only, I have no clue as to how this needs to be done in terms of code.
Class clsSO
{
void myVoid()
{
Console.WriteLine("We are here now ...");
}
} // End class
The above code would be wrapped in a .dll and added as a referenced dll to my project. The dll would then be referenced and the sub routine called:
clsSo myRef = new clsSo();
myRef.myVoid();
Console output reads:
We are here now…
What I need to be done:
The contents of the wrapper dll will be encrypted and thus unreadable / unable to reference the class directly. So, the dll will somehow need to be decrypted, and dynamically updated with the decrypted data so that I can then reference it.
Does something like this already exist? Can it even be done?
I appreciate the time everyone!
Thanks,
Evan
You will need to Call Assembly.Load(Byte[]) on the decrypted bytes of your file. once you have that you will need to either use reflection or cast the class to a interface so you can access the methods.
Here is a example
ReadFullyis from this posting. Read it to see why I did not just docryptoStream.Read(data, 0, decryptedLibArray.Length);There are some errors with the final example but the memory stream example he gives is perfect.However someone could just dump the ram of your program and get the decrypted binary, or possibly decompile your main program and get the decryption keys and just decrypt it themselves. So depending on how paranoid you are, you may still want to invest in a obfuscateor.