你的位置:首页 > ASP.net教程

[ASP.net教程]Software license key and activation


http://stackoverflow.com/questions/16222674/software-license-key-and-activation
https://github.com/Labs64
http://www.codeproject.com/Articles/11012/License-Key-Generation
https://ellipter.com/
https://technet.microsoft.com/en-us/library/dd346641(v=ws.10).aspx
https://code.msdn.microsoft.com/windowsapps/Product-Key-Activation-to-16c92174/view/SourceCode
https://activatar.codeplex.com/
http://dotlicense.codeplex.com/
http://www.codeproject.com/Articles/15496/Application-Trial-Maker
http://www.c-sharpcorner.com/article/a-simple-approach-to-product-activation/
http://www.codeproject.com/Articles/35009/How-to-Generate-and-Validate-CD-Keys-for-your-Soft
https://licensekeygenerator.codeplex.com/

http://softwareprotector.codeplex.com/

http://skgl.codeplex.com/

http://dotlicense.codeplex.com/

 

public static class Activation{  #region Redegit Key  public static void MakeRegeditActivationCode()  {    Registry.CurrentUser.CreateSubKey(@"SOFTWARE\Activation");  }  public static string ReadRegeditKey()  {    try    {      RegistryKey myKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Activation", true);      return myKey.GetValue("ActivationCode").ToString();    }    catch    {      SetRegeditKeyValue("");      return null;    }  }  public static void SetRegeditKeyValue(string value)  {    RegistryKey myKey = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Activation", true);    myKey.SetValue("ActivationCode", value, RegistryValueKind.String);  }  #endregion  #region Get Hardware Information  public static string GetMacAddress()  {    string macAddresses = "";    foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())    {      macAddresses = nic.GetPhysicalAddress().ToString();      break;    }    return macAddresses;  }  public static string GetCpuId()  {    string cpuid = null;    try    {      ManagementObjectSearcher mo = new ManagementObjectSearcher("select * from Win32_Processor");      foreach (var item in mo.Get())      {        cpuid = item["ProcessorId"].ToString();      }      return cpuid;    }    catch    {      return null;    }  }  #endregion  #region Hash Function  public static string MyCustomHash(string input)  {    System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();    byte[] bs = System.Text.Encoding.UTF32.GetBytes(input);    bs = x.ComputeHash(bs);    System.Text.StringBuilder s = new System.Text.StringBuilder();    int select = 1;    foreach (byte b in bs)    {      switch (select)      {        case 1:          s.Append(b.ToString("x4").ToLower());          break;        case 2:          s.Append(b.ToString("x3").ToLower());          break;        case 3:          s.Append(b.ToString("x2").ToLower());          break;        case 4:          s.Append(b.ToString("x1").ToLower());          break;        default:          break;      }      select++;      if (select > 4) select = 1;    }    string password = s.ToString();    return password;  }  #endregion}