Ejemplo n.º 1
0
        /// <summary>
        /// 登录校验方法
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <param name="pwd">密码的密文</param>
        /// <returns></returns>
        public JsonResult ValidateLogin(string userName, string pwd)
        {
            //密码先解码成原始密文
            pwd = StringUtils.Base64Decode(pwd);

            var matchedUser = service.GetMatchedUser(userName, pwd);

            if (matchedUser != null)
            {
                //初始化Session
                SetObjectToSession("UserInfo", matchedUser);
                //返回登录成功结果
                return(Json(new AjaxMessageDto
                {
                    success = true,
                    msg = "登录成功"
                }));
            }
            else
            {
                return(Json(new AjaxMessageDto
                {
                    success = false,
                    msg = "用户名或密码错误"
                }));
            }
        }
        public void Base64Test(string text)
        {
            string base64 = StringUtils.Base64Encode(text);

            Logger.WriteLine($"{text} - {base64}");
            Assert.Equal(text, StringUtils.Base64Decode(base64));
        }
Ejemplo n.º 3
0
        public static GlobalId FromGlobalId(string globalId)
        {
            var parts = StringUtils.Base64Decode(globalId).Split(':');

            return(new GlobalId {
                Type = parts[0],
                Id = string.Join(":", parts.Skip(count: 1)),
            });
        }
Ejemplo n.º 4
0
        public static Tuple <string, string> FromGlobalId(string globalId)
        {
            var parts = StringUtils.Base64Decode(globalId).Split(':');

            return(new Tuple <string, string>(
                       parts[0],
                       string.Join(":", parts.Skip(1))
                       ));
        }
Ejemplo n.º 5
0
        public static void ShouldDecode()
        {
            var decoded           = "U29tZSB0ZXh0IHdpdGggw7HDp8OhIGNoYXJhY3RlcnMu";
            var expectedPlainText = "Some text with ñçá characters.";

            var actualPlainText = StringUtils.Base64Decode(decoded);

            actualPlainText.Should().Be(expectedPlainText);
        }
Ejemplo n.º 6
0
 public static int CursorToOffset(string cursor)
 {
     return(int.Parse(
                StringUtils.Base64Decode(cursor).Substring(PREFIX.Length + 1)
                ));
 }
 public void Base64EncodeDecodeTest(string text, string base64)
 {
     Assert.Equal(text, StringUtils.Base64Decode(base64));
     Assert.Equal(base64, StringUtils.Base64Encode(text));
 }