Beispiel #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("");
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// 获取具有标准的Base64密码表的加密类
        /// </summary>
        /// <returns></returns>
        public static Base64Util GetStandardBase64()
        {
            Base64Util b64 = new Base64Util();

            b64.Pad       = "=";
            b64.CodeTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
            return(b64);
        }
Beispiel #3
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);
        }
Beispiel #4
0
 /// <summary>
 /// 加密字符串
 /// </summary>
 /// <param name="input"></param>
 /// <returns></returns>
 public static string EncryptString(string input)
 {
     return(MD5Util.AddMD5Profix(Base64Util.Encrypt(MD5Util.AddMD5Profix(input))));
     //return Base64.Encrypt(MD5.AddMD5Profix(Base64.Encrypt(input)));
 }