Пример #1
0
        public void TestReg()
        {
            string text = "1";

            //string key = "87654321";
            //string sbuff = DESEncrypt.EncryptHas(text, key);
            //string date = "2017-10-13";
            //DateTime dt = Convert.ToDateTime(date);

            byte[] data = Encoding.ASCII.GetBytes(text);

            byte[]        miwen = YSEncrypt.EncryptFishFile(data);
            StringBuilder ret   = new StringBuilder();

            foreach (byte b in miwen)
            {
                ret.AppendFormat("{0:X2}", b);
            }
            string mw = ret.ToString();

            int len;

            len = mw.Length / 2;
            byte[] inputByteArray = new byte[len];
            int    x, i;

            for (x = 0; x < len; x++)
            {
                i = Convert.ToInt32(mw.Substring(x * 2, 2), 16);
                inputByteArray[x] = (byte)i;
            }

            byte[] mingwen = YSEncrypt.DecryptData(inputByteArray);

            string result = Encoding.ASCII.GetString(mingwen);
            //string url = "http://192.168.1.10:11005/api/user/MemberRegister?username=w11111&userpwd=123123&yzm=1231&useryz=1231&fw=1231";
            //UserController user = new UserController();
            //user.MemberRegister("w21111", "123123", "1231", "1231", "1231");
            //string msg = Tz.Core.HttpMethods.HttpGet(url);
        }
Пример #2
0
        public IHttpActionResult MemberRegister(string username, string userpwd, string verify, string yzm, string useryz, string fw)
        {
            Log.Debug("这个是用户注册方法");
            Regex accountRex = new Regex("^[A-Za-z0-9_][A-Za-z0-9_]*$");

            if (!accountRex.IsMatch(username))
            {
                return(Json(3));
            }
            Log.Debug("返回token:" + fw);
            string code = Cache.Get(fw)?.ToString();

            Log.Debug("服务器保存的验证码:" + code);
            Log.Debug("用户传递的验证码:" + Md5.md5(yzm.ToLower(), 16));
            string yzmMd5 = Md5.md5(yzm.ToLower(), 16);

            if (code != yzmMd5)
            {
                return(Json(2));
            }

            DbHelper helper = new DbHelper("QpAccount");

            string  sql = string.Format("select * from account where account='{0}'", username);
            DataSet ds  = helper.GetDataTablebySQL(sql);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(Json(4));
            }

            string  sqlMaxNum = "select MAX(AccountNum) from Account";
            DataSet dsMaxNum  = helper.GetDataTablebySQL(sqlMaxNum);
            int     num       = 100000;

            if (dsMaxNum.Tables[0].Rows.Count > 0)
            {
                num = dsMaxNum.Tables[0].Rows[0][0].ToInt() + 1;
            }

            int len;

            len = verify.Length / 2;
            byte[] inputByteArray = new byte[len];
            int    x, i;

            for (x = 0; x < len; x++)
            {
                i = Convert.ToInt32(verify.Substring(x * 2, 2), 16);
                inputByteArray[x] = (byte)i;
            }

            byte[] mingwen = YSEncrypt.DecryptData(inputByteArray);

            string str = Encoding.ASCII.GetString(mingwen);


            string account           = username;
            string password          = userpwd;
            string accounttype       = "11";
            string accountsecondtype = "0";
            string sex        = "2";
            string nickname   = "新手" + num;
            string accountnum = num.ToString();
            string ipaddress  = Net.Ip;
            string mac        = string.Join(" , ", Tz.Core.Net.GetMacByNetworkInterface());
            string details    = "|||0|0|||||||";
            //|密保问题|密保答案|年龄|身高cm|学历|生肖|星座|职业|省|市|
            //string[] userInfo = details.Split('|');
            //string mbwt = userInfo[1];
            //string mbda = userInfo[2];
            //string age = userInfo[3];
            //string sg = userInfo[4];
            //string xl = userInfo[5];
            //string sx = userInfo[6];
            //string xz = userInfo[7];
            //string zy = userInfo[8];
            //string sheng = userInfo[9];
            //string shi = userInfo[10];

            string realname    = "";
            string idntirycard = "";
            string telephone   = "";
            string parentid    = "";
            string Url         = GetUrlStr() + string.Format("ysfunction={0}&account={1}&password={2}&accounttype={3}&accountsecondtype={4}&sex={5}&nickname={6}&accountnum={7}&ipaddress={8}&mac={9}&details={10}",
                                                             "register", account, password, accounttype, accountsecondtype, sex, nickname, accountnum, ipaddress, mac, details);
            string msg     = HttpMethods.HttpGet(Url);
            Regex  rex     = new Regex(@"(-\d+|\d+)<");
            int    result  = 0;
            string respson = rex.Match(msg).Groups[1].Value;

            Log.Debug(msg);
            if (respson != "-1" && respson != "-3" && respson != "-999" && respson != "-404")
            {
                result = 0;
            }
            else
            {
                result = respson.ToInt();
            }
            return(Json(result));
        }
Пример #3
0
        public IHttpActionResult TouristLogin(string verify)
        {
            Log.Debug("这个是游客登陆方法");

            string upwd = "c8c8e2585e7555ee27396f4645b415ff";

            Regex accountRex = new Regex("^[A-Za-z0-9_][A-Za-z0-9_]*$");
            int   len;

            len = verify.Length / 2;
            byte[] inputByteArray = new byte[len];
            int    x, i;

            for (x = 0; x < len; x++)
            {
                i = Convert.ToInt32(verify.Substring(x * 2, 2), 16);
                inputByteArray[x] = (byte)i;
            }

            byte[] mingwen = YSEncrypt.DecryptData(inputByteArray);

            string   macAddress = Encoding.ASCII.GetString(mingwen);
            DbHelper helper     = new DbHelper("QpAccount");
            int      rows       = 0;
            string   uname      = string.Empty;

            do
            {
                uname = BuildAccount();
                string  sql = string.Format("select * from account where account='{0}'", uname);
                DataSet ds  = helper.GetDataTablebySQL(sql);
                rows = ds.Tables[0].Rows.Count;
            } while (rows > 0);


            string  sqlMaxNum = "select MAX(AccountNum) from Account";
            DataSet dsMaxNum  = helper.GetDataTablebySQL(sqlMaxNum);
            int     num       = 100000;

            if (dsMaxNum.Tables[0].Rows.Count > 0)
            {
                num = dsMaxNum.Tables[0].Rows[0][0].ToInt() + 1;
            }


            string account           = uname;
            string password          = upwd;
            string accounttype       = "11";
            string accountsecondtype = "0";
            string sex        = "2";
            string nickname   = uname;
            string accountnum = num.ToString();
            string ipaddress  = Net.Ip;
            string mac        = Net.GetMacAddress();// string.Join(" , ", Tz.Core.Net.GetMacByNetworkInterface());
            string details    = "|||0|0|||||||";
            //|密保问题|密保答案|年龄|身高cm|学历|生肖|星座|职业|省|市|
            //string[] userInfo = details.Split('|');
            //string mbwt = userInfo[1];
            //string mbda = userInfo[2];
            //string age = userInfo[3];
            //string sg = userInfo[4];
            //string xl = userInfo[5];
            //string sx = userInfo[6];
            //string xz = userInfo[7];
            //string zy = userInfo[8];
            //string sheng = userInfo[9];
            //string shi = userInfo[10];

            string realname    = "";
            string idntirycard = "";
            string telephone   = "";
            string parentid    = "";
            string Url         = GetUrlStr() + string.Format("ysfunction={0}&account={1}&password={2}&accounttype={3}&accountsecondtype={4}&sex={5}&nickname={6}&accountnum={7}&ipaddress={8}&mac={9}&details={10}",
                                                             "register", account, password, accounttype, accountsecondtype, sex, nickname, accountnum, ipaddress, mac, details);
            string msg     = HttpMethods.HttpGet(Url);
            Regex  rex     = new Regex(@"(-\d+|\d+)<");
            string result  = "0";
            string respson = rex.Match(msg).Groups[1].Value;

            Log.Debug(msg);
            if (respson != "-1" && respson != "-3" && respson != "-999" && respson != "-404")
            {
                result = "0&" + uname + "&" + upwd;
            }
            else
            {
                result = respson;
            }
            return(Json(result));
        }