Example #1
0
        /// <summary>
        /// 解密加过密的字符串
        /// </summary>
        /// <param name="input"></param>
        /// <param name="throwException">解密失败是否抛异常</param>
        /// <returns></returns>
        public static string DecryptString(string input, bool throwException)
        {
            string res = "";

            try
            {
                res = input;// Base64.Decrypt(input);
                if (MD5Util.ValidateValue(res))
                {
                    return(MD5Util.RemoveMD5Profix(Base64Util.Decrypt(MD5Util.RemoveMD5Profix(res))));
                }
                else
                {
                    throw new Exception("字符串无法转换成功!");
                }
            }
            catch
            {
                if (throwException)
                {
                    throw;
                }
                else
                {
                    return("");
                }
            }
        }
Example #2
0
        /// <summary>
        /// 检查用户的授权码
        /// </summary>
        /// <returns></returns>
        public static LicenseCheckResult CheckLicense()
        {
            LicenseCheckResult result  = new LicenseCheckResult();
            string             license = MyConstants.License;

            if (!string.IsNullOrEmpty(license))
            {
                try
                {
                    string   decodeLicense = Base64Util.Decrypt(MD5Util.RemoveMD5Profix(license));
                    string[] strArray      = decodeLicense.Split('|');
                    if (strArray.Length >= 4)
                    {
                        string componentType = strArray[0];
                        if (componentType.ToLower() == "whc.pager")
                        {
                            result.IsValided = true;
                        }
                        result.Username    = strArray[1];
                        result.CompanyName = strArray[2];
                        try
                        {
                            result.DisplayCopyright = Convert.ToBoolean(strArray[3]);
                        }
                        catch
                        {
                            result.DisplayCopyright = true;
                        }

                        return(result);

                        #region 设置显示内容
                        //string displayText = string.Format("该组件已授权给:");
                        //if (!string.IsNullOrEmpty(LicenseResult.CompanyName))
                        //{
                        //    displayText += string.Format("{0}", LicenseResult.CompanyName);
                        //}
                        //if (!string.IsNullOrEmpty(LicenseResult.Username))
                        //{
                        //    displayText += string.Format(" ({0})", LicenseResult.Username);
                        //}
                        //this.tssLink.Text = displayText;
                        //this.tssLink.Visible = LicenseResult.DisplayCopyright;
                        #endregion
                    }
                }
                catch
                {
                }
            }

            return(result);
        }