Read "read the following article" crack others application of the article feeling, brief. NET application authorization. ", the actual operation of their own to come to the experience. Here is the principle of the background AH What is not introduced, laugh at life has been written on his blog is quite clear, what does not understand the details can go to see the original. Recommend the first look at the original text, now look at my next steps, and then go back to study the details of the original. Because I write my own example is used in a company project, the source code is not convenient to put out, hehe.
First step: Generate a set of public and private keys, the public key for you to publish the program, the private key belongs to the registration code generation. View Plaincopy to Clipboardprint?
using (rsacryptoserviceprovider RSA = new RSACryptoServiceProvider ())
{
//Public key
String pubkey = RSA. Toxmlstring (FALSE);
//private key
string prikey = RSA. Toxmlstring (TRUE);
//If it is WebForm on Response.Write (PubKey + "<br/>" + Prikey); under
//If WinForm on MessageBox.Show ("Public key:" + PubKey + "RN private key:" + Prikey); Under
}
using (rsacryptoserviceprovider RSA = new RSACryptoServiceProvider ())
{
//public key
string PubKey = RSA. Toxmlstring (false);
Private key
String prikey = RSA. Toxmlstring (true);
If it is WebForm Response.Write (PubKey + "<br/>" + Prikey); Under
//If the WinForm is MessageBox.Show ("Public key:" + PubKey + "RN private key:" + Prikey); Next
}
Step two: Get the machine hardware code. I choose the number of the cup. View Plaincopy to Clipboardprint?
<summary>
///Get CPU number
///</summary>
///<returns></returns>
Public String Getcpuid ()
{
ManagementClass mc = new ManagementClass ("Win32_Processor");
Managementobjectcollection MOC = MC. GetInstances ();
String strcpuid = null;
foreach (ManagementObject mo in MoC)
{
strcpuid = mo. properties["Processorid"]. Value.tostring (); Break
;
return
strcpuid;
}
///<summary>
///get CPU number
///</summary>
///<returns></returns> Public
string Getcpuid ()
{
ManagementClass mc = new ManagementClass ("Win32_Processor");
Managementobjectcollection MOC = MC. GetInstances ();
String strcpuid = null;
foreach (ManagementObject mo in MoC)
{
strcpuid = mo. properties["Processorid"]. Value.tostring ();
break;
return strcpuid;
}