程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> .NET網頁編程 >> C# >> C#入門知識 >> Software license key and activation,licenseactivation

Software license key and activation,licenseactivation

編輯:C#入門知識

Software license key and activation,licenseactivation


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

}

  

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved