Class library and security in dotnet technology

Suppose I have a class library, and I want me to be able to use this library only in my project, but if someone tries to copy the DLL file and wants to use it in their project, then he will not be able to do this. so I just want to know how to include this type of security in a DLL file ... please tell me in all ways. thanks

+4
source share
4 answers

You can check in your assembly PublicKeyToken the called signed assembly.

The second example is in VB.NET, the C # version could not be found, but you get this idea.

Remember that this is not an absolutely safe way, because someone else can decompile your assembly. But if it's just to prevent your library from being used in other projects, this might be an acceptable way.

+3
source

Verify the signature of the calling assembly and sign the assembly from which you are invoking the dll. Then sign the dll.

+3
source

You can use licensing technology when creating an instance of the library. What I did in the past is to include the public key as a resource in the dll, and then look for the license xml document with a cryptographic signature signed with my private key. As I continue to keep track of my private key, it’s pretty hard to win.

Having said that .Net is highly decompiled, be sure and obfuscate it with a tool like Dotfuscator.

+2
source

Not safe, but much harder to use: you can integrate dll into your main exe or web.dll using

+2
source

Source: https://habr.com/ru/post/1336502/


All Articles