On the topic of strong name, there are a lot of this introduction on the Internet, you probably most familiar with the impression is this
Most of the situation, that's it. If the code is confidential, it may also use the delay sign only, which is more complicated, please find the relevant information.
If you do this, there is no processing in the code, maybe your program is not safe, because there is a strong Name remover can easily clear your signature, it runs like this
If you don't want your program to be tortured by this little program, you should look at this article.
Just having a signature is not enough, you also need to detect the signature in your assembly, and the detected signature can only be my own name.
Locate the command line in Visual Studio tools, start it, and execute SN–TP application, as shown in
It shows the public key token, write it down, and I'll use it later in my program. Then write the code that detects the signature, as shown in the code below
public static void Preinitcoresetup () {//check singature bool pfwasverifie D = FALSE; string Fcommon = "Flextronics.Framework.Common.dll"; bool licensed = StrongNameSignatureVerificationEx (Fcommon, true, ref pfwasverified); if (!licensed) throw new fatalexception ( Shared.licenseexceptionerror)}
Looking at these words, it detects if an incoming application set has a signature, or if there is a strong name, and throws an exception if none. The native method is used here, and its signature is as follows
[dllimport ( "Mscoree.dll", CharSet = CharSet.Unicode)] Private static extern bool StrongNameSignatureVerificationEx (string FilePath, bool forceVerificatio N, ref bool wasverified);
To keep looking at the code, we don't just have to make sure that the assembly is signed, and that I have my own signature. Take a look at the program snippet below
PublicStaticvoid ensureassemblyissigned (Assembly Assembly) {if (assembly = null) throw new ArgumentNullException ( "assembly"); byte[] PubKey = assembly. GetName (). Getpublickeytoken (); if (PubKey. Length = = 0) throw new ArgumentException ( "No Public Key Token in assembly. "); StringBuilder builder = new StringBuilder (); foreach (byte b in PubKey) {Builder. AppendFormat ( "{0:x2}", b);} string pkstring = Builder. ToString (); if (pkstring! = Shared.publickkey) {throw new Fatalexception (Shared.licenseexceptionerror); }}
The meaning of these words is to get the signature of the Assembly, whether it is in accordance with our own signature, or if it is passed, terminates the program execution immediately.
The Shared.publickkey in the last sentence is the d1063c1538fcc2c8 shown in the last line of the SN in the above figure.
Starting program debugging, as seen in Visual Studio, shows the same Publick key as we see with the SN tool.
With these two steps, not only does the verification assembly have a signature, but it also has its own signature. Why do this, because strong name can be replaced, in the crack program, often used to replace the strong name, such as this program, it can implement the replacement assembly strong name
, select the specified assembly, and then specify a key, which enables the substitution of the strong name. Own hard to write the program, so easy to be cracked, you must be very uncomfortable, then please use this article introduced to you technology, apply strong name to protect your assembly.
Software cracking and protection, spear and shield struggle, hope this article can bring you help.
Please download the latest version of data Loader in Epn.codeplex.com (http://epn.codeplex.com/releases/view/68647).
Apply strong name to save the. NET application Set