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

            b64.Pad       = "=";
            b64.CodeTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
            return(b64);
        }
Exemplo n.º 3
0
        public static string DecryptString(string input, bool throwException)
        {
            string str = "";

            try
            {
                str = input;
                if (!MD5Util.ValidateValue(str))
                {
                    throw new Exception("字符串无法转换成功!");
                }
                return(MD5Util.RemoveMD5Profix(Base64Util.Decrypt(MD5Util.RemoveMD5Profix(str))));
            }
            catch
            {
                if (throwException)
                {
                    throw;
                }
                return("");
            }
        }
Exemplo n.º 4
0
 public static string EncryptString(string input)
 {
     return(MD5Util.AddMD5Profix(Base64Util.Encrypt(MD5Util.AddMD5Profix(input))));
 }
Exemplo n.º 5
0
 /// <summary>
 /// 获取具有标准的Base64密码表的加密类
 /// </summary>
 /// <returns></returns>
 public static Base64Util GetStandardBase64()
 {
     Base64Util b64 = new Base64Util();
     b64.Pad = "=";
     b64.CodeTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
     return b64;
 }