Example #1
0
 private static LicenseInfo GetLicense()
 {
     LicenseManager.CreateSnFile();
     #if TEST
     License = new LicenseInfo
     {
         ExpireDay = DateTime.MaxValue,
         NetName = "测试版(未授权)"
     };
     #else
     License = LicenseManager.GetLicenseInfo();
     #endif
     return License;
 }
Example #2
0
        public static LicenseInfo GetLicenseInfo()
        {
            var result = new LicenseInfo();
            try
            {

                var caPath = Environment.CurrentDirectory + "/ca.crt";
                var content = File.ReadAllText(caPath);
                content = EncryptHelper.AESDecrypt(EncryptHelper.FromBase64String(content));
                var i = 0;
                foreach (Match m in _caRegex.Matches(content))
                {
                    var val = m.Groups[1].Value;
                    if (i == 0)
                    {
                        result.NetName = val;
                    }
                    if (i == 1)
                    {
                        result.ExpireDay = DateTime.Parse(val);
                    }
                    if (i == 2)
                    {
                        result.HardwareID = val;
                    }
                    i++;
                }
                if (!string.IsNullOrEmpty(result.HardwareID))
                {
                    //硬件不匹配
                    if (GetProcessorID() + "|" + GetBoardID() != result.HardwareID)
                    {
                        return null;
                    }
                }

                return result;
            }
            catch
            {
                return null;
            }
        }