Exemple #1
0
        public void TestAes_2()
        {
            var encode = Encrypt.AesEncrypt("中国");

            _output.WriteLine(encode);
            Assert.Equal("中国", Encrypt.AesDecrypt(encode));
        }
        public void Test_Aes_2()
        {
            const string value  = "中国";
            var          encode = Encrypt.AesEncrypt(value);

            Output.WriteLine(encode);
            Assert.Equal(value, Encrypt.AesDecrypt(encode));
        }
Exemple #3
0
        private string GetUser()
        {
            var userCookie = HttpRequest.Cookies[CookieClaim];

            if (!string.IsNullOrEmpty(userCookie))
            {
                return(Encrypt.AesDecrypt(userCookie));
            }
            return(null);
        }
Exemple #4
0
        public static string GetUserLoginCookie()
        {
            var userCookie = HttpContextExt.Current.Request.Cookies[LoginCookieDto.CookieClaim];

            if (userCookie != null)
            {
                return(Encrypt.AesDecrypt(userCookie));
            }
            return(null);
        }
Exemple #5
0
        /// <summary>
        /// 解析请求信息
        /// </summary>
        private void ResolveRequestInfo()
        {
            var key      = Encrypt.Md5By32(_key).ToLower();
            var info     = Encrypt.AesDecrypt(GetRequestInfo(), key, Encoding.UTF8, CipherMode.ECB);
            var elements = Xml.ToElements(info);

            elements.ForEach(node => {
                _builder.Add(node.Name.LocalName, node.Value);
            });
        }
Exemple #6
0
        public static string GetUserLoginCookie()
        {
            //string cookieClaims = LoginCookieDto.CookieClaim;
            //var userPrincipal = HttpContextExt.Current.User;
            //var userCookie = (from c in userPrincipal.Claims
            //                  where c.Type == cookieClaims
            //                  select c.Value).FirstOrDefault();

            var userCookie = HttpContextExt.Current.Request.Cookies[LoginCookieDto.CookieClaim];

            if (userCookie != null)
            {
                return(Encrypt.AesDecrypt(userCookie));
            }
            return(null);
            // return userCookie;
        }
 public string GetValueKey(string filename)
 {
     string v = "";
     try
     {
         using (StreamReader sr = new StreamReader(filename))
         {
             v = sr.ReadToEnd();
         }
     }
     catch (Exception ex)
     {
         Logger.LogF(ex);
     }
     if (v != "")
         return Encrypt.AesDecrypt(v, EncryptKeys[0]);
     else
         return "";
 }
Exemple #8
0
 public void TestAes_Validate(string input, string key, string result)
 {
     Assert.Equal(result, Encrypt.AesEncrypt(input, key, Encoding.UTF8));
     Assert.Equal(result, Encrypt.AesDecrypt(input, key, Encoding.UTF8));
 }