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>
 /// <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)));
 }