コード例 #1
0
        /// <summary>
        /// 是否有效License
        /// 此方法校验License是否有效,是否过期;是否申请的机器
        /// 版本,人数第三系统自己校验
        /// </summary>
        /// <param name="info"></param>
        /// <param name="pubKey"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public static bool IsValidityLicense(LicenseInfo info, string pubKey, out string message)
        {
            message = string.Empty;
            //string key = iWS.Utility.Config.ConfigHelper.GetString("License_PublicKey");
            //if (!string.IsNullOrEmpty(key))
            //    pubKey = key;
            string hashData;

            info.MachineCode = MachineCode.GetMachineCode();
            string machineCode = MachineCode.GetMachineCode();

            RSACryption.GetHash(info.ToString(), out hashData);
            if (RSACryption.SignatureDeformatter(pubKey, hashData, info.SignatureInfo))
            {
                if (info.ExpireDate < DateTime.Now)
                {
                    message = "您的 license 已过期,请联系供应商,获取新的 license!";
                    return(false);
                }
                if (info.IssuedDate > DateTime.Now)
                {
                    message = "您的 license 已过期,请联系供应商,获取新的 license!";
                    return(false);
                }
                return(true);
            }
            message = "无效License!";
            return(false);
        }
コード例 #2
0
        /// <summary>
        /// 是否有效License
        /// 此方法校验License是否有效,是否过期;是否申请的机器
        /// 版本,人数第三系统自己校验
        /// </summary>
        /// <param name="info"></param>
        /// <param name="certName"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        public static bool IsValidityLicenseByCert(LicenseInfo info, string certName, out string message)
        {
            message = string.Empty;
            string cert = Config.ConfigHelper.GetAppSettingOrDefault("License_CertName");

            if (!string.IsNullOrEmpty(cert))
            {
                certName = cert;
            }
            string hashData;

            info.MachineCode = MachineCode.GetMachineCode();
            RSACryption.GetHash(info.ToString(), out hashData);
            var pubcert = RSACryption.X509CertCreatePublicKeyRSA(certName);

            if (RSACryption.SignatureDeformatter(pubcert, hashData, info.SignatureInfo))
            {
                if (info.ExpireDate < DateTime.Now)
                {
                    message = "您的 license 已过期,请联系供应商,获取新的 license!";
                    return(false);
                }
                if (info.IssuedDate > DateTime.Now)
                {
                    message = "您的 license 已过期,请联系供应商,获取新的 license!";
                    return(false);
                }
                return(true);
            }
            message = "无效License!";
            return(false);
        }