示例#1
0
        private static string genPackageSign(WXPrePost postParams)
        {
            //拼接排序list
            Dictionary <string, string> packageParams = new Dictionary <string, string>();

            packageParams.Add("appid", postParams.appid);
            packageParams.Add("body", postParams.body);
            packageParams.Add("detail", postParams.detail);
            packageParams.Add("mch_id", postParams.mch_id);
            packageParams.Add("nonce_str", postParams.nonce_str);
            packageParams.Add("notify_url", postParams.notify_url);
            packageParams.Add("out_trade_no", postParams.out_trade_no);
            packageParams.Add("spbill_create_ip", postParams.spbill_create_ip);
            packageParams.Add("total_fee", postParams.total_fee + "");
            packageParams.Add("trade_type", postParams.trade_type);
            StringBuilder sb = new StringBuilder();

            foreach (var packageParam in packageParams)
            {
                sb.Append(packageParam.Key);
                sb.Append('=');
                sb.Append(packageParam.Value);
                sb.Append('&');
            }
            sb.Append("key=");
            sb.Append(PartnerKey);//key设置路径:微信商户平台(pay.weixin.qq.com)-->账户设置-->API安全-->密钥设置
            //这里又用到了从实例代码复制的MD5 可以去上面copy
            String packageSign = MD5Tool.GetMD5(sb.ToString()).ToUpper();

            return(packageSign);
        }
示例#2
0
        //得到查询xml签名
        private static string GetQueryOrderPostSign(WXQueryOrderPost postParams)
        {
            //拼接排序list
            Dictionary <string, string> packageParams = new Dictionary <string, string>();

            packageParams.Add("appid", postParams.appid);
            packageParams.Add("mch_id", postParams.mch_id);
            packageParams.Add("nonce_str", postParams.nonce_str);
            packageParams.Add("out_trade_no", postParams.out_trade_no);
            StringBuilder sb = new StringBuilder();

            foreach (var packageParam in packageParams)
            {
                sb.Append(packageParam.Key);
                sb.Append('=');
                sb.Append(packageParam.Value);
                sb.Append('&');
            }
            sb.Append("key=");
            sb.Append(PartnerKey);//key设置路径:微信商户平台(pay.weixin.qq.com)-->账户设置-->API安全-->密钥设置
            //这里又用到了从实例代码复制的MD5 可以去上面copy
            String packageSign = MD5Tool.GetMD5(sb.ToString()).ToUpper();

            return(packageSign);
        }
示例#3
0
        public override void OnHandlerMessage(OperationRequest request, OperationResponse response, ClientPeer clientPeer,
                                              SendParameters sendParameters)
        {
            Dictionary <byte, object> parameters;

            parameters = request.Parameters;
            object jsonObj = null;

            parameters.TryGetValue((byte)ParameterCode.User, out jsonObj);
            MUser user;

            user = JsonMapper.ToObject <MUser>(jsonObj.ToString());
            IList <MUser> userDB;

            userDB = mgr.GetUserByName(user.UserName);
            foreach (MUser mUser in userDB)
            {
                if (mUser.PassWord == MD5Tool.GetMD5(user.PassWord))
                {
                    //username and password is correct, success , login
                    response.ReturnCode  = (short)ReturnCode.Success;
                    clientPeer.LoginUser = mUser;
                }
                else
                {
                    response.ReturnCode   = (short)ReturnCode.Fail;
                    response.DebugMessage = "username or password error !";
                }
            }
        }
示例#4
0
        public async Task <MessageModel <string> > CreateUser([FromBody] UserViewModel model)
        {
            var data = new MessageModel <string>();

            if (!ModelState.IsValid)
            {
            }
            try
            {
                await userService.CreateAsync(new User
                {
                    UserName    = model.UserName,
                    Pwd         = MD5Tool.Encrypt(model.UserPwd),
                    UserSex     = model.Sex,
                    RealName    = model.RealName,
                    Birthday    = model.Bridthday,
                    Phone       = model.Phone,
                    UserGroupId = model.GroupId
                });

                data.success  = true;
                data.msg      = "ok";
                data.response = "add User Success!!!";
            }
            catch (Exception ex)
            {
                data.msg      = "Error!!!";
                data.response = "add User Error!!!";
            }
            return(data);
        }
        /// <summary>
        /// 获取变量名称为所传参数的cookie的开始时间或结束时间,1:开始时间,2:结束时间
        /// </summary>
        /// <param name="cookiename">cookie的变量的名称</param>
        /// <param name="num">1:开始时间,2:结束时间</param>
        /// <returns></returns>
        public static DateTime GetCookieValue(string cookiename, int num)
        {
            DateTime value = DateTime.Now;

            try
            {
                if (IsHaveCookie(cookiename))
                {
                    //获取当前COOKIE
                    var user_cookie = CookieHelper_HongRenHui.GetCookie(MD5Tool.getMd5Hash(cookiename));
                    //登录票证
                    var user_ticket = FormsAuthentication.Decrypt(user_cookie);

                    if (num == 1)
                    {
                        //变量名称为RED_USERID的开始时间
                        value = user_ticket.IssueDate;
                    }
                    else
                    {
                        //变量名称为RED_USERID的过期时间
                        value = user_ticket.Expiration;
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return(value);
        }
示例#6
0
        public LoginResult Login(String username, String password)
        {
            RestClient  client  = new RestClient(ServerURL.URL);
            RestRequest request = new RestRequest("/api/account/authentication", Method.POST);

            request.AddHeader("X-Username", username);
            request.AddHeader("X-Password", MD5Tool.GetMD5(MD5Tool.GetMD5(MD5Tool.GetMD5(password) + username) + "1234"));
            var response = client.Execute <LoginResult>(request);

            if (response.StatusCode == HttpStatusCode.OK)
            {
                foreach (Parameter header in response.Headers)
                {
                    if (header.Name.Equals("X-Auth-Token"))
                    {
                        response.Data.token = header.Value.ToString();
                    }
                }
                return(response.Data);
            }
            else
            {
                return(null);
            }
        }
        /// <summary>
        /// 创建Cookie
        /// </summary>
        /// <param name="cookiename">Cookie的变量名称</param>
        /// <param name="value">Cookie的值</param>
        /// <param name="expires">Cookie的过期时间,默认为1</param>
        /// <param name="isexpires">是否存储过期时间</param>
        public static void AddCookie(string cookiename, string value, int expires, bool isexpires)
        {
            //设置过期时间默认值
            //if (expires < 1 || string.IsNullOrEmpty(expires.ToString()))
            //{
            //    expires = 1;
            //}
            if (string.IsNullOrEmpty(expires.ToString()))
            {
                expires = 1;
            }

            //创建票证
            FormsAuthenticationTicket RED_USERID_ticket = new FormsAuthenticationTicket(1, value, DateTime.Now, DateTime.Now.AddDays(expires), true, domin, "/");
            //给票证加密
            var now_ticket = FormsAuthentication.Encrypt(RED_USERID_ticket);

            //创建cookie并给cookie赋值
            CookieHelper_HongRenHui.WriteCookie(MD5Tool.getMd5Hash(cookiename), now_ticket, domin);
            //判断是否有过期时间
            if (isexpires)
            {
                //CookieHelper_HongRenHui.WriteCookie("expires", expires.ToString(), domin);
                //CookieHelper_HongRenHui.WriteCookie(new string[] { MD5Tool.getMd5Hash(cookiename) }, expires);
                CookieHelper_HongRenHui.WriteCookie(MD5Tool.getMd5Hash(cookiename), now_ticket, expires, domin);
            }
        }
示例#8
0
        /// <summary>
        /// 获取签名
        /// </summary>
        /// <param name="url">网址</param>
        /// <param name="apiKeyInfo">取用的Api密钥</param>
        /// <returns></returns>
        public static string GetSign(string url, ApiKeyInfo apiKeyInfo = null)
        {
            if (apiKeyInfo == null)
            {
                apiKeyInfo = AndroidKey;
            }
            string result;

            if (url.StartsWith("http"))
            {
                url.Substring(url.IndexOf("?", 4) + 1);
            }
            List <string> list = url.Split('&').ToList();

            list.Sort();
            StringBuilder stringBuilder = new StringBuilder();

            foreach (string str1 in list)
            {
                stringBuilder.Append((stringBuilder.Length > 0 ? "&" : string.Empty));
                stringBuilder.Append(str1);
            }
            stringBuilder.Append(apiKeyInfo.Secret);
            result = MD5Tool.GetMd5String(stringBuilder.ToString()).ToLower();
            System.Diagnostics.Debug.WriteLine("sign=" + result);
            return(result);
        }
示例#9
0
    /// <summary>
    /// 获得预支付订单
    /// </summary>
    /// <param name="e"></param>
    /// <param name="args"></param>
    private void OnPrePay(PrePay2Client e, object[] args)
    {
        if (e.storeName != StoreName.WX)
        {
            return;
        }

        Debug.LogWarning("OnPrePay=========:" + e.prepay_id + "=partnerId==");
        DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);

        string nonceStr       = "Random" + UnityEngine.Random.Range(10000, 99999).ToString();
        string timeStamp      = (new DateTime(DateTime.UtcNow.Ticks - dt1970.Ticks).AddHours(8).Ticks / 10000000).ToString();
        string stringA        = "appid=" + appid + "&" + "nonceStr=" + nonceStr + "&packageValue=Sign=WXPay&" + "partnerId=" + mchID + "&" + "prepayId=" + e.prepay_id + "&timeStamp=" + timeStamp;
        string stringSignTemp = stringA + "&key=" + appSecret;
        string sign           = MD5Tool.GetMD5FromString(stringSignTemp);

        OnPayInfo onPayInfo = new OnPayInfo();

        onPayInfo.isSuccess = true;
        onPayInfo.goodsId   = e.goodsID;
        onPayInfo.storeName = StoreName.WX;
        onPayInfo.receipt   = e.mch_orderID;
        onPayInfo.price     = payInfo.price;
        onPayInfo.goodsName = payInfo.goodsName;
        PayReSend.Instance.AddPrePayID(onPayInfo);
        IndentListener(e.goodsID, e.mch_orderID, e.prepay_id, nonceStr, timeStamp, sign, payInfo.price);
    }
示例#10
0
        /// <summary>
        /// 添加员工
        /// </summary>
        /// <param name="name">员工姓名</param>
        /// <param name="sex">员工性别</param>
        /// <param name="age">员工年龄</param>
        /// <param name="nation">员工民族</param>
        /// <param name="phone">员工手机</param>
        /// <param name="email">员工邮箱</param>
        /// <param name="DeptTxt">部门编号</param>
        /// <param name="StateTxt">状态编号</param>
        /// <returns></returns>
        public NewsModel AddStaff(string name, string sex, string age, string nation, string phone, string email, string DeptTxt, string StateTxt)
        {
            StaffManageDAL staffManageDAL = new StaffManageDAL();

            if (staffManageDAL.IsNullStaffByPhone(phone))
            {
                return(new NewsModel(false, "手机号已使用,无法录入!"));
            }
            Staff staff = new Staff();

            staff.Name             = name;
            staff.Sex              = sex.Equals("0") ? false : true;
            staff.Age              = Convert.ToInt32(age);
            staff.Nation           = nation;
            staff.Phone            = phone;
            staff.Email            = email;
            staff.DeptId           = Convert.ToInt32(DeptTxt);
            staff.EstablishDate    = DateTime.Now;
            staff.IsDelete         = false;
            staff.Password         = MD5Tool.MD5Encryption("1");
            staff.Staff_StateId    = Convert.ToInt32(StateTxt);
            staff.Staff_DdentityId = new StaffManageDAL().GetDdentityIdByDeptID(staff.DeptId);

            if (staffManageDAL.AddStaff(staff))
            {
                return(new NewsModel(true, "添加成功"));
            }
            return(new NewsModel(false, "添加失败"));
        }
示例#11
0
        //1:支付宝;2:微信支付
        public async Task OnGet(int num = 1, int _istype = 2)
        {
            await HttpContext.Session.LoadAsync();

            UserId = HttpContext.Session.GetString(UserAccountBusiness.UserAccountSessionkey);
            var dbTable          = userAccountBisness.userAccountAccessor.All <PayAPILog>();
            var _userId          = Guid.Parse(UserId);
            var sortedCollection = new SortedDictionary <string, string>();
            var userInfo         = await userAccountBisness.userAccountAccessor.OneAsync <UserAccountEntry>(x => x.Id == _userId, "InviteOrigin");

            //是否存在未处理订单
            var hasOrder = dbTable.Any(x => x.Statue != PayAPILogStatus.End || x.Statue != PayAPILogStatus.Error && x.UserAccountId == _userId);

            if (num < 30)
            {
                num = 30;
            }
            var orderId = Guid.NewGuid();

            if (!hasOrder)
            {
                dbTable.Add(new PayAPILog
                {
                    CreateTime    = DateTime.Now,
                    Id            = orderId,
                    PayNum        = num,
                    Statue        = PayAPILogStatus.Create,
                    UserAccountId = _userId
                });
                await userAccountBisness.userAccountAccessor.SaveAsync();
            }
            OrderId   = orderId.ToString();
            GoodsName = "趣漫画会员支付";
            price     = num;

            istype = _istype;
            if (userInfo?.InviteOrigin?.InviteKey == "lnn")
            {
                price = 0.01;
            }
            sortedCollection.Add("goodsname", GoodsName);
            sortedCollection.Add("price", price.ToString());
            sortedCollection.Add("istype", _istype.ToString());
            sortedCollection.Add("orderid", orderId.ToString());
            sortedCollection.Add("orderuid", OrderUId);
            sortedCollection.Add("token", token);
            sortedCollection.Add("return_url", returnUrl);
            sortedCollection.Add("notify_url", notifyUrl);
            sortedCollection.Add("uid", uid);
            var stringKey = new StringBuilder();

            foreach (var item in sortedCollection)
            {
                stringKey.Append(item.Value);
            }
            var tmpStr = stringKey.ToString();

            Key = MD5Tool.GetMD532(tmpStr);
        }
示例#12
0
        public override void OnHandleMessage(OperationRequest request, OperationResponse response, MasterClientPeer peer, SendParameters sendParameters)
        {
            var user   = ParameterTool.GetParameter <User>(request.Parameters, ParameterCode.User);
            var userDB = manager.GetUserByAccesstoken(user.Accesstoken);

            SubCode subCode = ParameterTool.GetSubcode(request.Parameters);

            ParameterTool.AddSubcode(response.Parameters, subCode);
            switch (subCode)
            {
            case SubCode.AccLogin:
            {
                if (userDB != null && userDB.Password == MD5Tool.GetMD5(user.Password))
                {
                    ParameterTool.AddParameter <User>(response.Parameters, ParameterCode.User, userDB);
                    //用户名和密码正确,登陆成功
                    response.ReturnCode = (short)ReturnCode.Success;
                    peer.User           = userDB;


                    //if (MasterApplication.Instance.TeamCtrl.ContansUser(userDB.ID))//如果之前正在游戏中
                    //{
                    //    peer.Team = MasterApplication.Instance.TeamCtrl.GetTeamByUser(userDB.ID);
                    //}
                }
                else
                {
                    response.ReturnCode   = (short)ReturnCode.Fail;
                    response.DebugMessage = "用户名或密码错误";
                }
                //string username = ParameterTool.GetParameter<string>(request.Parameters, ParameterCode.Username, false);
                // password = ParameterTool.GetParameter<string>(request.Parameters, ParameterCode.Password, false);
                Log("Login:acesstoken=" + user.Accesstoken + ",password="******"用户已存在";
                }
                //string username = ParameterTool.GetParameter<string>(request.Parameters, ParameterCode.Username, false);
                //string password = ParameterTool.GetParameter<string>(request.Parameters, ParameterCode.Password, false);
                Log("Register:acesstoken=" + user.Accesstoken + ",password=" + user.Password);
            } break;
            }
        }
示例#13
0
    static AESTools()
    {
        string code_key = MD5Tool.GetMd5Hash("soulgame");
        string code_iv  = MD5Tool.GetMd5Hash("bear");

        //Rfc2898DeriveBytes rfc = new Rfc2898DeriveBytes("soulgame", Encoding.UTF8.GetBytes("garfield"));
        //Key = rfc.GetBytes (32);
        //IV = rfc.GetBytes (16);
        Key = Encoding.UTF8.GetBytes(code_key.Substring(0, 16));
        IV  = Encoding.UTF8.GetBytes(code_iv.Substring(0, 16));
        //Debug.Log (Key.Length);
        //Debug.Log (IV.Length);
    }
示例#14
0
        /// <summary>
        /// 判断变量名称为RED_USERID的cookie是否存在
        /// </summary>
        /// <returns></returns>
        public static bool IsHaveCookie()
        {
            bool f = true;
            //获取当前COOKIE
            var user_cookie = CookieHelper.GetCookie(MD5Tool.getMd5Hash("RED_USERID"));

            //登录票证
            if (string.IsNullOrEmpty(user_cookie))
            {
                f = false;
            }
            return(f);
        }
示例#15
0
    static void VersionsDifferenceZipImp(string oldVersionDir, string newVersionDir)
    {
        oldVersionDir = MyFileUtil.DealFilePathSlash(oldVersionDir);
        newVersionDir = MyFileUtil.DealFilePathSlash(newVersionDir);

        List <string> oldFileList = new List <string>();
        List <string> newFileList = new List <string>();

        MyFileUtil.GetFileList(oldVersionDir, ref oldFileList);
        MyFileUtil.GetFileList(newVersionDir, ref newFileList);

        List <string> modificationFileList = new List <string>();

        foreach (string newFilePath in newFileList)
        {
            int index = oldFileList.IndexOf(newFilePath);
            if (index < 0)
            {
                //添加新的文件
                modificationFileList.Add(newFilePath);
            }
            else
            {
                string oldFilePath = oldFileList[index];
                if (MD5Tool.VerifyFile(newFilePath, oldFilePath) == false)
                {
                    //文件改变
                    modificationFileList.Add(newFilePath);
                }
            }
        }

        //string time = System.DateTime.Now.ToString("yyyy_MM_dd_hh_mm_ss");

        string modificationDir = MyFileUtil.GetParentDir(newVersionDir) + "update_tmp";

        MyFileUtil.DeleteDir(modificationDir);
        MyFileUtil.CreateDir(modificationDir);

        foreach (string filePath in modificationFileList)
        {
            string newFilePath = filePath.Replace(newVersionDir, modificationDir);
            MyFileUtil.CopyFile(filePath, newFilePath);
        }

        string zipFilePath = modificationDir + ".zip";

        ZIPTool.CompressDirectory(modificationDir, zipFilePath, 0, false);

        Debug.Log("");
    }
        /// <summary>
        /// 判断变量名称为所传参数的cookie是否存在
        /// </summary>
        /// <param name="cookiename">cookie的变量的名称</param>
        /// <returns></returns>
        public static bool IsHaveCookie(string cookiename)
        {
            bool f = true;
            //获取当前COOKIE
            var user_cookie = CookieHelper_HongRenHui.GetCookie(MD5Tool.getMd5Hash(cookiename));

            //登录票证
            if (string.IsNullOrEmpty(user_cookie))
            {
                f = false;
            }

            return(f);
        }
示例#17
0
        public static void setPayDtltoRedis(DataModel data, string orderMid, string memUuid, IRedisHelper rds)
        {
            PaymentDtl payDtl = new PaymentDtl();

            payDtl.currency       = data.currency;
            payDtl.orderMid       = orderMid;
            payDtl.payMethod      = data.payMethod;
            payDtl.currTotalPrice = Convert.ToDouble(data.currPriceTotal);
            payDtl.paymentToken   = MD5Tool.GetMD5(orderMid + memUuid + Website.Instance.Configuration["kkdayKey:payDtl"].ToString());

            string payDtlStr = JsonConvert.SerializeObject(payDtl);

            rds.SetRedis(payDtlStr, "b2d:ec:payDtl:" + orderMid, 60);
        }
示例#18
0
    //生成游戏中使用的配置文件
    public void CreatBundelPackageConfig()
    {
        Dictionary <string, object> data = new Dictionary <string, object>();

        Dictionary <string, object> gameRelyBundles = new Dictionary <string, object>();

        for (int i = 0; i < relyPackages.Count; i++)
        {
            //生成游戏中使用的依赖包数据
            Dictionary <string, object> pack = new Dictionary <string, object>();
            pack.Add("name", relyPackages[i].name);
            pack.Add("path", relyPackages[i].path);
            pack.Add("relyPackages", new string[0]);
            pack.Add("md5", MD5Tool.GetFileMD5(GetExportPath(relyPackages[i].path, relyPackages[i].name))); //获取bundle包的md5

            gameRelyBundles.Add(relyPackages[i].name, pack);
        }

        Dictionary <string, object> gameAssetsBundles = new Dictionary <string, object>();

        for (int i = 0; i < bundles.Count; i++)
        {
            //生成游戏中使用的bundle包数据
            Dictionary <string, object> pack = new Dictionary <string, object>();
            pack.Add("name", bundles[i].name);
            pack.Add("path", bundles[i].path);
            pack.Add("relyPackages", GetRelyPackNames(bundles[i].relyPackagesMask));              //获取依赖包的名字
            pack.Add("md5", MD5Tool.GetFileMD5(GetExportPath(bundles[i].path, bundles[i].name))); //获取bundle包的md5
            //pack.loadType      = ResLoadType.Streaming;  //默认放在沙盒路径下

            gameAssetsBundles.Add(bundles[i].name, pack);
        }

        data.Add(ResourcesConfigManager.c_relyBundleKey, gameRelyBundles);
        data.Add(ResourcesConfigManager.c_bundlesKey, gameAssetsBundles);

        //保存游戏中读取的配置文件
        //ConfigManager.SaveData(ResourcesConfigManager.c_configFileName, gameConfig);

        float time = Time.realtimeSinceStartup;

        EditorUtil.WriteStringByFile(
            PathTool.GetAbsolutePath(ResLoadLocation.Resource,
                                     ResourcesConfigManager.c_ManifestFileName + "." + ConfigManager.c_expandName)
            , FrameWork.Json.Serialize(data));

        Debug.Log("保存完毕 序列化时间: " + (Time.realtimeSinceStartup - time));

        AssetDatabase.Refresh();
    }
示例#19
0
        public override void OnHandlerMessage(OperationRequest request, OperationResponse response, ClientPeer peer, SendParameters sendParameters)
        {
            Dictionary <byte, object> m_dic = request.Parameters;
            object value;
            string strUserName;
            string strUserPassword;

            if (m_dic.TryGetValue((byte)ParameterCode.UserRegiste, out value))
            {
                string strValue = value.ToString();
                strValue.Trim();
                log.Debug("UserRegisteHandler Get Data:" + strValue);
                string[] pStr = strValue.Split(',');
                if (pStr.Length == 2)
                {
                    strUserName     = pStr[0];
                    strUserPassword = pStr[1];
                    log.Debug("RegisterName:" + strUserName + "--RegisterPassword:"******"用户名重复!";
                        return;
                    }
                    else
                    {
                        User newUser = new User();
                        newUser.Name = strUserName;
                        string strMD5 = MD5Tool.StringToMD5(strUserPassword);
                        newUser.Password = strMD5;
                        int nID = m_mgr.AddUser(newUser);
                        peer.m_curUser = newUser;
                        Dictionary <byte, object> dic = new Dictionary <byte, object>();
                        dic.Add((byte)ParameterCode.UserRegiste, nID.ToString());
                        Helper.Log("注册新用户:" + nID.ToString());
                        response.Parameters = dic;
                        response.ReturnCode = (short)ReturnCode.Success;
                        log.Debug("UserRegiste Success: Add New User:"******"--P:" + strUserPassword + "--MD5:" + strMD5);
                        return;
                    }
                }
            }

            response.ReturnCode = (short)ReturnCode.Error;
            log.Debug("Login Error");
        }
示例#20
0
        public override void OnHandlerMessage(OperationRequest request, OperationResponse response, ClientPeer peer, SendParameters sendParameters)
        {
            User user   = ParameterTool.GetParameter <User>(request.Parameters, ParameterCode.User);
            User userDB = manager.GetUserByUsername(user.Username);

            if (userDB != null)
            {
                response.ReturnCode   = (short)ReturnCode.Fail;
                response.DebugMessage = "用户名重复";
            }
            else
            {
                user.Password = MD5Tool.GetMD5(user.Password);
                manager.AddUser(user);
                response.ReturnCode = (short)ReturnCode.Success;
            }
        }
示例#21
0
    /// <summary>
    /// 获得预支付订单
    /// </summary>
    /// <param name="e"></param>
    /// <param name="args"></param>
    private void OnPrePay(PrePay2Client e, object[] args)
    {
        WXListener.Instance.GetComponent <WXListener>().GoodId = e.goodsID;

        Debug.LogWarning("OnPrePay=========:" + e.prepay_id + "=partnerId==");
        DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);

        string nonceStr       = "Random" + UnityEngine.Random.Range(10000, 99999).ToString();
        string timeStamp      = (new DateTime(DateTime.UtcNow.Ticks - dt1970.Ticks).AddHours(8).Ticks / 10000000).ToString();
        string stringA        = "appid=wx3ce30b3054987098&" + "nonceStr=" + nonceStr + "&packageValue=Sign=WXPay&" + "partnerId=1526756671&" + "prepayId=" + e.prepay_id + "&timeStamp=" + timeStamp;
        string stringSignTemp = stringA + "&key=a8f73a2a5ecfafab1ea80515ef0efbad";
        string sign           = MD5Tool.GetMD5FromString(stringSignTemp);

        WXListener.Instance.GetComponent <WXListener>().Mch_orderID = e.mch_orderID;

        IndentListener(e.prepay_id, nonceStr, timeStamp, sign);
    }
示例#22
0
    //获得lua zip文件md5值
    public void GetLuaZipFileMD5(string luaCodeZipFileName, System.Action <string> getFinish)
    {
        Action <byte[]> loadZip = delegate(byte[] data)
        {
            if (data == null)
            {
                string str = string.Format("ResourcesManager.GetLuaZipFileMD5:加载Lua代码文件失败");
                Debug.LogError(str);
                getFinish("");
                return;
            }

            string md5 = MD5Tool.Get(data);
            getFinish(md5);
        };

        StartCoroutine(LoadLuaZipFileImp(luaCodeZipFileName, loadZip));
    }
示例#23
0
    IEnumerator DownLoadResItemImp(ResInfo item, int totalCount, int current, System.Action <bool, string, ResInfo> updateFinish)
    {
        //WWW www = new WWW(item.resURL);
        WWW www = HTTPTool.GetWWW(item.resURL);

        //ui提示
        UIWindowUpdate.Instance.ShowDownloadTips(totalCount, current + 1, item.resName, www, item.resSize);
        UIWindowFirstLoading.Hide();

        yield return(www);

        if (string.IsNullOrEmpty(www.error) == false)
        {
            //下载出错
            Debug.LogError(www.error + item.resURL);
            // updateFinish(false, "资源下载失败,请点击重试", item);
            updateFinish(false, LanguageConfig.GetText(5), item);
            yield break;
        }
        else
        {
            UIWindowUpdate.Instance.ShowVerifyTips();
            UIWindowFirstLoading.Hide();
            if (MD5Tool.Verify(www.bytes, item.resMD5))
            {
                //解压文件--下载成功
                UIWindowUpdate.Instance.ShowUnZipTips();
                UIWindowFirstLoading.Hide();
                ZIPTool.DecompressToDirectory(www.bytes, MyFileUtil.CacheDir);
                updateFinish(true, "", item);
            }
            else
            {
                //md5 匹配不上
                string str = string.Format("VersionManager.DownLoadResImp:资源{0} md5出错", item.resURL);
                Debug.LogError(str);

                // updateFinish(false, "资源校验失败,md5值不匹配,请点击重新下载", item);
                updateFinish(false, LanguageConfig.GetText(6), item);
                yield break;
            }
        }
    }
        public override string generateRegistCode(string macNum)
        {
            setIntCode();                             //初始化127位数组
            for (int i = 1; i < Charcode.Length; i++) //把机器码存入数组中
            {
                Charcode[i] = Convert.ToChar(macNum.Substring(i - 1, 1));
            }
            for (int j = 1; j < intNumber.Length; j++)//把字符的ASCII值存入一个整数组中。
            {
                intNumber[j] = intCode[Convert.ToInt32(Charcode[j])] + Convert.ToInt32(Charcode[j]);
            }
            string strAsciiName = "";//用于存储注册码

            for (int j = 1; j < intNumber.Length; j++)
            {
                if (intNumber[j] >= 48 && intNumber[j] <= 57)//判断字符ASCII值是否0-9之间
                {
                    strAsciiName += Convert.ToChar(intNumber[j]).ToString();
                }
                else if (intNumber[j] >= 65 && intNumber[j] <= 90)//判断字符ASCII值是否A-Z之间
                {
                    strAsciiName += Convert.ToChar(intNumber[j]).ToString();
                }
                else if (intNumber[j] >= 97 && intNumber[j] <= 122)//判断字符ASCII值是否a-z之间
                {
                    strAsciiName += Convert.ToChar(intNumber[j]).ToString();
                }
                else//判断字符ASCII值不在以上范围内
                {
                    if (intNumber[j] > 122)//判断字符ASCII值是否大于z
                    {
                        strAsciiName += Convert.ToChar(intNumber[j] - 10).ToString();
                    }
                    else
                    {
                        strAsciiName += Convert.ToChar(intNumber[j] - 9).ToString();
                    }
                }
            }
            //获取的机器码,打上软件标识再进行一次MD5
            strAsciiName = MD5Tool.md5(strAsciiName + ActivityConst.SOFT_FLAG_FOR_REGISTER).ToUpper();
            return(strAsciiName);
        }
示例#25
0
    /// <summary>
    /// 获得预支付订单
    /// </summary>
    /// <param name="e"></param>
    /// <param name="args"></param>
    private void OnPrePay(PrePay2Client e, object[] args)
    {
        Debug.LogWarning("OnPrePay=========:" + e.prepay_id + "=partnerId==");
        DateTime dt1970 = new DateTime(1970, 1, 1, 0, 0, 0, 0);

        string nonceStr       = "Random" + UnityEngine.Random.Range(10000, 99999).ToString();
        string timeStamp      = (new DateTime(DateTime.UtcNow.Ticks - dt1970.Ticks).AddHours(8).Ticks / 10000000).ToString();
        string stringA        = "appid=wx3ce30b3054987098&" + "nonceStr=" + nonceStr + "&packageValue=Sign=WXPay&" + "partnerId=1526756671&" + "prepayId=" + e.prepay_id + "&timeStamp=" + timeStamp;
        string stringSignTemp = stringA + "&key=a8f73a2a5ecfafab1ea80515ef0efbad";
        string sign           = MD5Tool.GetMD5FromString(stringSignTemp);

        OnPayInfo onPayInfo = new OnPayInfo();

        onPayInfo.isSuccess = true;
        onPayInfo.goodsId   = e.goodsID;
        onPayInfo.storeName = StoreName.WX;
        //WXPayReSend.Instance.AddPrePayID(onPayInfo);
        IndentListener(e.prepay_id, nonceStr, timeStamp, sign);
    }
    //生成游戏中使用的配置文件
    public void CreatBundelPackageConfig()
    {
        Dictionary <string, SingleField> gameConfig = new Dictionary <string, SingleField>();

        Dictionary <string, ResourcesConfig> gameRelyBundles = new Dictionary <string, ResourcesConfig>();

        for (int i = 0; i < relyPackages.Count; i++)
        {
            //生成游戏中使用的依赖包数据
            ResourcesConfig pack = new ResourcesConfig();
            pack.name         = relyPackages[i].name;
            pack.path         = relyPackages[i].path;
            pack.relyPackages = new string[0];
            pack.md5          = MD5Tool.GetFileMD5(GetExportPath(pack.path, pack.name));  //获取bundle包的md5
            //pack.loadType      = ResLoadType.Streaming;  //默认放在沙盒路径下

            gameRelyBundles.Add(pack.name, pack);
        }

        Dictionary <string, ResourcesConfig> gameAssetsBundles = new Dictionary <string, ResourcesConfig>();

        for (int i = 0; i < bundles.Count; i++)
        {
            //生成游戏中使用的bundle包数据
            ResourcesConfig pack = new ResourcesConfig();
            pack.name         = bundles[i].name;
            pack.path         = bundles[i].path;
            pack.relyPackages = GetRelyPackNames(bundles[i].relyPackagesMask);           //获取依赖包的名字
            pack.md5          = MD5Tool.GetFileMD5(GetExportPath(pack.path, pack.name)); //获取bundle包的md5
            //pack.loadType      = ResLoadType.Streaming;  //默认放在沙盒路径下

            gameAssetsBundles.Add(pack.name, pack);
        }

        gameConfig.Add(ResourcesConfigManager.c_relyBundleKey, new SingleField(JsonTool.Dictionary2Json <ResourcesConfig>(gameRelyBundles)));
        gameConfig.Add(ResourcesConfigManager.c_bundlesKey, new SingleField(JsonTool.Dictionary2Json <ResourcesConfig>(gameAssetsBundles)));

        //保存游戏中读取的配置文件
        ConfigManager.SaveData(ResourcesConfigManager.c_configFileName, gameConfig);
        AssetDatabase.Refresh();
    }
示例#27
0
        public override void OnHandlerMessage(Photon.SocketServer.OperationRequest request, OperationResponse response, ClientPeer peer, SendParameters sendParameters)
        {
            Dictionary <byte, object> parameters = request.Parameters;
            object jsonObject = null;

            parameters.TryGetValue((byte)ParameterCode.User, out jsonObject);
            User user   = JsonMapper.ToObject <User>(jsonObject.ToString());
            User userDB = manager.GetUserByUsername(user.Username);

            if (userDB != null && userDB.Password == MD5Tool.GetMD5(user.Password))
            {
                //用户名和密码正确 登录成功
                response.ReturnCode = (short)ReturnCode.Success;
                peer.LoginUser      = userDB;
            }
            else
            {
                response.ReturnCode   = (short)ReturnCode.Fail;
                response.DebugMessage = "用户名或密码错误!";
            }
        }
示例#28
0
        public override void OnHandlerMessage(OperationRequest request, OperationResponse response, ClientPeer peer, SendParameters sendParameters)
        {
            Dictionary <byte, object> m_dic = request.Parameters;
            object value;
            string strUserName;
            string strUserPassword;

            if (m_dic.TryGetValue((byte)ParameterCode.UserLogin, out value))
            {
                string strValue = value.ToString();
                strValue.Trim();
                log.Debug("LoginHandle Get Data:" + strValue);
                string[] pStr = strValue.Split(',');
                if (pStr.Length == 2)
                {
                    strUserName     = pStr[0];
                    strUserPassword = pStr[1];
                    log.Debug("UserName:" + strUserName + "--UserPassword:"******"Login Success");
                            return;
                        }
                    }
                }
            }

            response.ReturnCode = (short)ReturnCode.Error;
            log.Debug("Login Error");
        }
示例#29
0
        public async Task RegisterUser(UserAccount userAccount)
        {
            var userModel = new UserAccount
            {
                Id         = Guid.NewGuid(),
                CreateTime = DateTime.Now,
                Password   = MD5Tool.GetMD532(userAccount.Password),
                UserName   = userAccount.UserName
            };
            await sugarClient.Insertable <UserAccount>(userModel).ExecuteCommandAsync();

            var userCount = await sugarClient.Queryable <UserAccount>().CountAsync();

            await sugarClient.Insertable <UserInfoEntry>(new UserInfoEntry
            {
                Id         = Guid.NewGuid(),
                CreateTime = DateTime.Now,
                ArthorId   = userModel.Id.ToString(),
                Avarta     = "~/images/avarta.png",
                NicName    = "用户" + userCount.ToString().PadLeft(4, '0')
            }).ExecuteCommandAsync();
        }
        /// <summary>
        /// 获取变量名称为所传参数的cookie的值
        /// </summary>
        /// <param name="cookiename">cookie的变量的名称</param>
        /// <returns></returns>
        public static string GetCookieValue(string cookiename)
        {
            string value = "0";

            try
            {
                if (IsHaveCookie(cookiename))
                {
                    //获取当前COOKIE
                    var user_cookie = CookieHelper_HongRenHui.GetCookie(MD5Tool.getMd5Hash(cookiename));
                    //登录票证
                    var user_ticket = FormsAuthentication.Decrypt(user_cookie);

                    //获取变量名称为RED_USERID的cookie的值
                    value = user_ticket.Name;
                }
            }
            catch (Exception ex)
            {
            }
            return(value);
        }