Пример #1
0
        public void TestDeEncrypter()
        {
            var secret = @"MbT0uM2xs54lhPrwW/Z6DzOlyk0Dw39cUeHdxzi8qEz8Jf53RHivZ/g/8EXgObzEOlBwc00eQ2X7VUYwzNs4Rg==";
            var para   = Encrypter.DecryptDes(secret);

            Console.WriteLine(para);
            secret = @"d3eb9a9233e52948740d7eb8c3062d14";
            para   = Encrypter.EncryptMd5(secret);
            Console.WriteLine(para);
        }
        public bool Modify(string username, string newPassword, string oldPassword, string telephone = "", string displayName = "", bool md5 = true)
        {
            var paras = new Dictionary <string, string>
            {
                { "userName", username },
                { "newPassword", md5?newPassword: Encrypter.EncryptMd5(newPassword) },
                { "oldPassword", md5?oldPassword: Encrypter.EncryptMd5(oldPassword) },
                { "telephone", telephone },
                { "displayName", displayName }
            };
            var ret  = WebHelper.Get(ModifyUrl, paras);
            var reto = JsonConvert.DeserializeObject <Net965808Ret>(ret);

            return(reto != null && reto.IsOk());
        }
        public bool Login(string username, string pwd, out string userid, out string msg, bool md5 = true)
        {
            msg    = "登录失败";
            userid = "";
            if (!md5)
            {
                pwd = Encrypter.EncryptMd5(pwd);
            }
            var para = string.Format("userName={0},password={1}", username, pwd);
            var ret  = WebHelper.Get(LoginUrl, para);
            var reto = JsonConvert.DeserializeObject <Net965808Ret>(ret);

            if (reto == null)
            {
                return(false);
            }
            userid = reto.userId;
            msg    = reto.message;
            return(reto.IsOk());
        }
        public bool Regist(string username, string pwd, out string msg, bool md5 = true)
        {
            msg = "注册失败";
            var paras = new Dictionary <string, string>
            {
                { "loginId", username },
                { "password", md5?pwd: Encrypter.EncryptMd5(pwd) },
                { "displayName", username },
                { "duty", "" },
                { "mobile", "" }
            };
            var ret  = WebHelper.Get(RegisterUrl, paras);
            var reto = JsonConvert.DeserializeObject <Net965808Ret>(ret);

            if (reto == null)
            {
                return(false);
            }
            msg = reto.message;
            return(reto.IsOk());
        }