Ejemplo n.º 1
0
 public void SetGameSetting()
 {
     game_setting = JsonConvert.DeserializeObject <Dictionary <string, SettingItem> >(Settings.Default.GameSetting);
     //ServerUrl = AESEncrypt.Decrypt(Settings.Default.ServerUrl, secret_key);
     if (string.IsNullOrEmpty(Settings.Default.ServerUrl))
     {
         ServerUrl = "127.0.0.1";
     }
     else
     {
         ServerUrl = AESEncrypt.Decrypt(Settings.Default.ServerUrl, secret_key);
     }
     //保存的是当前运行的局数
     CurSessionIndex        = Settings.Default.CurrentSessionIndex;
     _is_print_bill         = GetStrSetting("is_print_bill");
     _betSpeed              = GetIntSetting("bet_speed");
     _round_num_per_session = GetIntSetting("round_num_per_session");
     _is3SecOn              = GetStrSetting("open_3_sec") == "3秒功能开" ? true : false;
     _betTime             = GetIntSetting("bet_tm"); //押注时间有几秒
     _check_waybill_tm    = GetIntSetting("check_waybill_tm");
     _mi_deal_time        = GetIntSetting("mi_deal_time");
     _deal_style          = GetStrSetting("deal_style");
     _big_chip_facevalue  = GetIntSetting("big_chip_facevalue");
     _mini_chip_facevalue = GetIntSetting("mini_chip_facevalue");
     _min_limit_bet       = GetIntSetting("min_limit_bet");
     _total_limit_red     = GetIntSetting("total_limit_red");
     _can_cancle_bet      = GetIntSetting("can_cancle_bet");
     _desk_limit_red      = GetIntSetting("desk_limit_red");
     _tie_limit_red       = GetIntSetting("tie_limit_red");
     _limit_red_on_3sec   = GetStrSetting("limit_red_on_3sec") == "超限红可试分" ? true : false;
     _print_font          = GetStrSetting("print_font");
     _single_double       = GetStrSetting("single_double");
     _bgm_on = GetStrSetting("bgm") == "背景音乐开" ? true : false;
     _boom   = GetIntSetting("boom");
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Decrypt byte array and convert to object
 /// </summary>
 /// <param name="message"></param>
 /// <returns></returns>
 public static object Deserialize(byte[] message)
 {
     using (var memoryStream = new MemoryStream(AESEncrypt.decryptStream(message, AESEncrypt.Tempkey, AESEncrypt.TempIV)))
     {
         return(new BinaryFormatter().Deserialize(memoryStream));
     }
 }
Ejemplo n.º 3
0
        //获取任务
        public Dictionary <string, string> GetTask(long userid)
        {
            string message;
            long   taskid;
            int    state = Task(userid, out taskid);

            if (state == 0)
            {
                message = "没有任务";
            }
            else if (state == 1)
            {
                message = "未完成";
            }
            else if (state == 2)
            {
                message = "已完成";
            }
            else
            {
                message = "任务异常";
            }

            Dictionary <string, string> dic = new Dictionary <string, string>();

            dic.Add("state", state.ToString());                        //状态,0:没有任务,1:未完成,2:已完成
            dic.Add("statetext", message);                             //状态说明
            dic.Add("taskkey", AESEncrypt.Encrypt(taskid.ToString())); //任务KEY
            dic.Add("task", getParamVarchar("RunTask"));               //任务步数
            LogHelper.SaveLog(string.Format("获取任务 taskkey:{0} ,taskid:{1}", AESEncrypt.Encrypt(taskid.ToString()), taskid), "task");
            return(dic);
        }
Ejemplo n.º 4
0
 public bool FindPwdDataDecode(string data, out string account, out int userid)
 {
     try
     {
         var adminStrs = data.Split('$');
         if (adminStrs.Length == 2)
         {
             userid = int.Parse(adminStrs[1]);
             var key = SecretKey.GetKey(CustomConfig.FindPwdEmailTicks, userid.ToString());
             SecretKey.KeyDelete(CustomConfig.FindPwdEmailTicks, userid.ToString());
             var loginStrs = AESEncrypt.Decode(adminStrs[0], key).Split('|');
             if (loginStrs.Length == 2)
             {
                 var expireTime = DateTime.Parse(loginStrs[1]);
                 if (expireTime > DateTime.Now)
                 {
                     account = loginStrs[0];
                     return(true);
                 }
             }
         }
     }
     catch { }
     account = null;
     userid  = 0;
     return(false);
 }
Ejemplo n.º 5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (!Page.IsPostBack)
         {
             if (Request.Cookies["UserInfo"] != null)
             {
                 string userName = Request.Cookies["UserInfo"]["UserName"];
                 if (!string.IsNullOrWhiteSpace(userName))
                 {
                     AESEncrypt aes = new AESEncrypt();
                     ltrMyData.Text = "<div id=\"myData\" style=\"display:none;\">[{\"UserName\":\"" + aes.DecryptString(Server.HtmlEncode(userName)) + "\"}]</div>";
                 }
             }
         }
         else
         {
             OnLogin();
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string errorMsg = string.Empty;

            try
            {
                if (!Page.IsPostBack)
                {
                    if (Request.Cookies["UserInfo"] != null)
                    {
                        string userName = Request.Cookies["UserInfo"]["UserName"];
                        if (!string.IsNullOrWhiteSpace(userName))
                        {
                            AESEncrypt aes = new AESEncrypt();
                            ltrMyData.Text = "<div id=\"myData\" style=\"display:none;\">[{\"UserName\":\"" + aes.DecryptString(Server.HtmlEncode(userName)) + "\"}]</div>";
                        }
                    }
                }
                else
                {
                    OnLogin();
                }
            }
            catch (Exception ex)
            {
                errorMsg = ex.Message;
            }

            if (!string.IsNullOrEmpty(errorMsg))
            {
                MessageBox.Messager(this.Page, Page.Controls[0], errorMsg, MessageContent.AlertTitle_Sys_Info);
                return;
            }
        }
Ejemplo n.º 7
0
        private string GenerateCheckCode(HttpContext context)
        {
            string checkCode = String.Empty;

            rnd = new Random();

            char[] character = { '2', '3', '4', '5', '6', '8', '9', 'a', 'b', 'd', 'e', 'f', 'h', 'k', 'm', 'n', 'r', 'x', 'y', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'W', 'X', 'Y' };

            int charLen = character.Length;

            for (int i = 0; i < 4; i++)
            {
                checkCode += character[rnd.Next(charLen)];
            }

            string cookieName = GetCookieName(context);

            if (cookieName != "")
            {
                AESEncrypt aes = new AESEncrypt();
                context.Response.Cookies["ValidateCode"][cookieName] = aes.EncryptString(checkCode);
            }

            return(checkCode);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 解析授权文件获取到授权信息
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public LicenceModel GetLicenceModel(string filePath)
        {
            if (!FileHelper.IsExistFile(filePath))
            {
                throw new CustomException("未找到授权文件!");
            }

            licenceObj = new LicenceModel();
            using (FileStream filestrem = new FileStream(filePath, FileMode.Open))
            {
                using (StreamReader reader = new StreamReader(filestrem))
                {
                    string typeStr = AESEncrypt.Decrypt(reader.ReadLine());
                    licenceObj.LicenceType = (LicenseTypeEnum)Enum.Parse(typeof(LicenseTypeEnum), typeStr, true);
                    string keyStr = reader.ReadLine();
                    licenceObj.PublicKey = AESEncrypt.Decrypt(keyStr);
                    licenceObj.Licence   = reader.ReadLine();
                }
            }

            string licenceStr = Base64Encrypt.Decrypt(licenceObj.Licence);
            string oStr       = RSAEncryptExt.DecryptString(licenceStr, licenceObj.PublicKey);

            string[] tempStrs = oStr.Split('&');
            licenceObj.MCode = tempStrs[0];

            string[] dateStrs = tempStrs[1].Split('|');
            licenceObj.AllData = dateStrs[0] == "true";
            licenceObj.Date    = Ext.UnixTimeToTime(dateStrs[1]);
            string[] userNumStrs = tempStrs[2].Split('|');
            licenceObj.AllUser = userNumStrs[0] == "true";
            licenceObj.UserNum = Convert.ToInt32(userNumStrs[1]);

            return(licenceObj);
        }
Ejemplo n.º 9
0
        public static List <SelectOption> RespondUserSelect()
        {
            string key = cache_response_user + "0";
            List <SelectOption> options = (List <SelectOption>)DataCache.GetCache(key);

            if (options == null)
            {
                string[] auths = { "财务管理", "系统管理" };
                options = (from op in (from user in db.User_Infos
                                       join uvr in db.User_vs_Roles on user.user_id equals uvr.uvr_user_id
                                       join rva in db.Role_vs_Authority on uvr.uvr_role_id equals rva.rva_role_id
                                       join auth in db.Sys_Authority on rva.rva_auth_id equals auth.auth_id
                                       where user.user_state == 1 && auths.Contains(auth.auth_name)
                                       group user by new { user.user_id, user.real_name } into p
                                       select new
                {
                    id = p.Key.user_id,
                    text = p.Key.real_name
                }).ToList()
                           select new SelectOption
                {
                    id = op.id.ToString(),
                    text = AESEncrypt.Decrypt(op.text)
                }).ToList();
                if (options.Count() > 0)
                {
                    DataCache.SetCache(key, options);
                }
            }
            return(options);
        }
Ejemplo n.º 10
0
        public static string unPackage(string jstr)
        {
            JObject obj = new JObject();
            string  md5;
            string  js = "";

            try
            {
                obj = (JObject)JsonConvert.DeserializeObject(jstr);
                md5 = obj["sign"].ToString();
                string data = obj["data"].ToString();
                js = AESEncrypt.Decrypt(data, key);
                string checkMD5 = ComMD5.GetMd5Str(js);
                if (md5 == checkMD5)
                {
                    return(js);
                }
                else
                {
                    js = "";
                }
            }
            catch
            {
            }
            return(js);
        }
Ejemplo n.º 11
0
        public static byte[] Build(byte[] data)
        {
            byte[] buffer = data;
            byte[] key    = null;
            byte[] iv     = null;

            byte[] keyData;
            byte[] ivData;
            BuildAESKey(out keyData, out ivData);

            buffer = AESEncrypt.Encrypt(buffer, 0, buffer.Length, keyData, ivData);

            key = RSASend.Encrypt(keyData, true);
            iv  = RSASend.Encrypt(ivData, true);

            List <byte> dataList = new List <byte>();

            if (null == key)
            {
                dataList.Add(0);
                dataList.Add(0);
                dataList.AddRange(buffer);
            }
            else
            {
                dataList.AddRange(BitConverter.GetBytes((ushort)key.Length));
                dataList.AddRange(key);
                dataList.AddRange(BitConverter.GetBytes((ushort)iv.Length));
                dataList.AddRange(iv);
                dataList.AddRange(buffer);
            }

            return(dataList.ToArray());
        }
Ejemplo n.º 12
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            string dd = AESEncrypt.Encrypt("{\"cmd\":0,\"value\":\"hello\",\"status\":0}", "12345678900000001234567890000000");

            tbAesTest.Text    = dd;
            tbENcoderLen.Text = dd.Length.ToString();
        }
Ejemplo n.º 13
0
        public JsonResult SetResetPassword(int?us_idx)
        {
            try
            {
                if (us_idx == null)
                {
                    throw new Exception(Resources.Resource.res0219);//잘못된 호출입니다.
                }

                UserModel chkUser = Mapper.Instance().QueryForObject <UserModel>("User.selUser", new UserModel {
                    us_idx = us_idx
                });

                Mapper.Instance().Update("User.udtUser", new UserModel {
                    us_idx = us_idx, login_pw = AESEncrypt.AESEncrypt256(CommonUtil.DefaultPassword(), chkUser.login_id.Trim())
                });

                return(Json(1));
            }
            catch (Exception ex)
            {
                Mapper.Instance().RollBackTransaction();
                logger.Error(string.Format("ERROR : 시스템 설정 저장"), ex);
                return(Json(new ResultJsonModel {
                    isError = true, resultMessage = ex.Message, resultDescription = ex.ToString()
                }));
            }
        }
Ejemplo n.º 14
0
        private string GenerateCheckCode(HttpContext context)
        {
            string checkCode = String.Empty;

            rnd = new Random();

            char[] character = { '2', '3', '4', '5', '6', '8', '9', 'a', 'b', 'd', 'e', 'f', 'h', 'k', 'm', 'n', 'r', 'x', 'y', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'W', 'X', 'Y' };

            int charLen = character.Length;

            for (int i = 0; i < 4; i++)
            {
                checkCode += character[rnd.Next(charLen)];
            }

            string cookieName = GetCookieName(context);

            if (cookieName != "")
            {
                AESEncrypt aes    = new AESEncrypt();
                HttpCookie cookie = new HttpCookie(cookieName, aes.EncryptString(checkCode));
                cookie.HttpOnly = true;
                cookie.Expires  = DateTime.Now.AddMinutes(5); //注意:bug,设置Expires将导致获取不到cookie
                context.Response.Cookies.Add(cookie);
            }

            return(checkCode);
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 密码计算规则
        /// </summary>
        /// <param name="password">密码</param>
        /// <param name="secretKey">SecretKey</param>
        /// <returns>加密后的密码</returns>
        public static string CaculatePWD(string password, string secretKey)
        {
            string pwd       = password.ToLower();
            string aesString = AESEncrypt.Encrypt(pwd, secretKey).ToLower();
            string md5String = Md5.md5(aesString, 32).ToLower();

            return(md5String);
        }
Ejemplo n.º 16
0
        public void SaveJsonPlayersScoreToDefault(ObservableCollection <Player> players)
        {
            var json = JsonConvert.SerializeObject(players);
            var text = AESEncrypt.Encrypt(json, secret_key);

            Settings.Default.JsonPlayerScores = text;
            Settings.Default.Save();
        }
Ejemplo n.º 17
0
 /// <summary>
 /// Convert Object to encrypted byte array
 /// </summary>
 /// <param name="anySerializableObject"></param>
 /// <returns></returns>
 public static byte[] Serialize(object anySerializableObject)
 {
     using (var memoryStream = new MemoryStream())
     {
         new BinaryFormatter().Serialize(memoryStream, anySerializableObject);
         return(AESEncrypt.encryptStream(memoryStream.ToArray(), AESEncrypt.Tempkey, AESEncrypt.TempIV));
     }
 }
Ejemplo n.º 18
0
        //校验 身份证 姓名
        private string VerifyIdenCode(HttpContext context)
        {
            string message = string.Empty;

            string jsondata = context.Request["data"] ?? "";

            LogHelper.SaveLog(jsondata, "VerifyIdenCode");
            RegisterModel rModel = null;

            try
            {
                jsondata = AESEncrypt.Decrypt(jsondata);
                rModel   = JsonConvert.DeserializeObject <RegisterModel>(jsondata);
            }
            catch
            {
                return(ResultJson(ResultType.error, "数据异常", ""));
            }
            if (string.IsNullOrEmpty(rModel.idencode))//|| recommendcode.Length != 18)
            {
                return(ResultJson(ResultType.error, "身份证错误", ""));
            }

            if (string.IsNullOrEmpty(rModel.idenname) || rModel.idenname.Length < 2)
            {
                return(ResultJson(ResultType.error, "姓名错误", ""));
            }

            string strswitch = System.Configuration.ConfigurationManager.AppSettings["IDCARD_SWITCH"];

            UserService userSvc   = new UserService();
            int         idcodenum = userSvc.GetIDCodeNumber(rModel.idencode);

            if (idcodenum >= userSvc.getParamInt("SystemName6"))
            {
                return(ResultJson(ResultType.error, "您的身份证已验证,不能重复验证", ""));
            }

            IDAuthentication auth      = new IDAuthentication();
            string           resultmsg = auth.AuthenticationIDAndName(rModel.idencode, rModel.idenname);

            if (resultmsg != "success")
            {
                return(ResultJson(ResultType.error, "身份证验证失败", ""));
            }


            bool result = userSvc.SaveIdenCode(long.Parse(rModel.userid), rModel.idencode, rModel.idenname);

            if (result)
            {
                return(ResultJson(ResultType.success, "验证通过", ""));
            }
            else
            {
                return(ResultJson(ResultType.error, "验证失败", ""));
            }
        }
Ejemplo n.º 19
0
        public static byte[] Read(Stream stream)
        {
            List <byte> dataList = new List <byte>();

            byte[] buffer  = new byte[512];
            int    readLen = 0;

            while ((readLen = stream.Read(buffer, 0, 512)) > 0)
            {
                for (int i = 0; i < readLen; i++)
                {
                    dataList.Add(buffer[i]);
                }
            }

            buffer = dataList.ToArray();

            if (buffer.Length == 0)
            {
                return(buffer);
            }

#if Encrypt
            int    index  = 0;
            ushort keyLen = BitConverter.ToUInt16(buffer, index);
            index += 2;

            if (keyLen == 0)
            {
                buffer = AESEncrypt.Decrypt(buffer, index, buffer.Length - index);
            }
            else
            {
                byte[] keyData = new byte[keyLen];
                Array.Copy(buffer, index, keyData, 0, keyLen);
                index += keyLen;

                ushort ivLen = BitConverter.ToUInt16(buffer, index);
                index += 2;

                byte[] ivData = new byte[ivLen];
                Array.Copy(buffer, index, ivData, 0, ivLen);
                index += ivLen;

                try
                {
                    byte[] key = RSAReceive.Decrypt(keyData, true);
                    byte[] iv  = RSAReceive.Decrypt(ivData, true);
                    buffer = AESEncrypt.Decrypt(buffer, index, buffer.Length - index, key, iv);
                }
                catch (Exception exc)
                {
                    Console.WriteLine(exc);
                }
            }
#endif
            return(buffer);
        }
Ejemplo n.º 20
0
        public Task <int> RevisePassword(string userPassword, string keyValue)
        {
            UserLogOnEntity userLogOnEntity = new UserLogOnEntity();

            userLogOnEntity.Id            = keyValue;
            userLogOnEntity.UserSecretkey = Md5.md5(Common.CreateNo(), 16).ToLower();
            userLogOnEntity.UserPassword  = Md5.md5(AESEncrypt.Encrypt(userPassword.ToLower(), userLogOnEntity.UserSecretkey).ToLower(), 32).ToLower();
            return(service.UpdateAsync(userLogOnEntity));
        }
Ejemplo n.º 21
0
        private string PacketReceive(HttpContext context)
        {
            string userid    = context.Request["userid"] ?? "";
            string packetkey = context.Request["packetkey"] ?? "";
            string type      = context.Request["type"] ?? "";

            string message = string.Empty;

            if (string.IsNullOrEmpty(userid))
            {
                return(ResultJson(ResultType.error, "用户ID不能为空", ""));
            }

            if (string.IsNullOrEmpty(packetkey))
            {
                return(ResultJson(ResultType.error, "请输入红包key", ""));
            }

            if (string.IsNullOrEmpty(type))
            {
                return(ResultJson(ResultType.error, "红包类型不能为空", ""));
            }

            int _type = 0;

            int.TryParse(type, out _type);

            if (!(_type == 1 || _type == 2))
            {
                return(ResultJson(ResultType.error, "红包类型无效", ""));
            }

            long _userid    = 0;
            long _receiveid = 0;

            long.TryParse(userid, out _userid);

            string receiveid;

            try
            {
                receiveid = AESEncrypt.Decrypt(packetkey);
            }
            catch (Exception ex)
            {
                LogHelper.SaveLog("PacketReceive" + ex.ToString(), "packet");
                return(ResultJson(ResultType.error, "红包KEY无效", ""));
            }

            long.TryParse(receiveid, out _receiveid);
            LogHelper.SaveLog(string.Format("PacketReceive -> userid:{0},receiveid:{1},type:{2}", _userid, _receiveid, _type), "packet");
            PacketService svc    = new PacketService();
            var           result = svc.PacketReceive(_userid, _receiveid, _type, out message);

            return(ResultJson(ResultType.success, "ok", result));
        }
Ejemplo n.º 22
0
        void Application_Start(object sender, EventArgs e)
        {
            // 在应用程序启动时运行的代码
            string a = "13594663608";
            string b = AESEncrypt.AesEncrypt(a);
            string c = DESEncrypt.Encrypt(a);
            string d = DESEncrypt.Encrypt2(a);

            string h = Convert.ToBase64String(Guid.NewGuid().ToByteArray());
        }
Ejemplo n.º 23
0
        public string FindPwdDataEncode(int userid, string account)
        {
            var endTime = DateTime.Now.AddHours(1);
            var str     = account + "|" + endTime.ToString();
            var key     = SecretKey.GetKey(CustomConfig.FindPwdEmailTicks, userid.ToString());
            var result  = AESEncrypt.Encode(str, key);

            result = result + "$" + userid.ToString();
            return(result);
        }
Ejemplo n.º 24
0
        //完成任务 timelong:时长 ,donenum:完成步数
        public bool DoneTask(long userid, string taskkey, string timelong, string donenum, out string message)
        {
            long _taskid;

            int state = Task(userid, out _taskid);

            //if (state == 0) message = "任务超时";
            //else if (state == 1) message = "未完成";
            //else if (state == 2) message = "已完成";
            //else message = "任务异常";
            LogHelper.SaveLog(string.Format("完成任务 taskkey:{0} ,taskid:{1}", taskkey, AESEncrypt.Encrypt(_taskid.ToString())), "task");
            if (taskkey != AESEncrypt.Encrypt(_taskid.ToString()))
            {
                message = "任务已过期";
                return(false);
            }

            if (state != 1)
            {
                message = "任务不存在";
                return(false);
            }

            int cheat = getParamInt("RunTaskCheatSwith");

            if (cheat == 1)
            {
                message = getParamVarchar("RunTaskCheatTip");
                return(false);
            }

            int result = flag_Award_TaskDone(userid, _taskid, timelong, donenum);

            if (result == 0)
            {
                message = "任务成功完成";
            }
            else if (result == 1)
            {
                message = "任务不存在,奖金已发完";
                return(false);
            }
            else if (result == 2)
            {
                message = "任务不存在,或任务已完成";
                return(false);
            }
            else
            {
                message = getParamVarchar("RunTaskCheatTip");
                return(false);
            }

            return(true);
        }
Ejemplo n.º 25
0
        private void btnDecrypt_Click(object sender, EventArgs e)
        {
            //ICryptoTransform transform = provider.CreateDecryptor();
            //byte[] decryptTextBytes = Convert.FromBase64String(encryptText);
            //byte[] decryptBytes = transform.TransformFinalBlock(decryptTextBytes, 0, decryptTextBytes.Length);
            //rtbOutput.Text = ASCIIEncoding.ASCII.GetString(decryptBytes);

            AESEncrypt aes = new AESEncrypt(key, InitVector, pm);

            rtbOutput.Text = aes.Decrypt(encryptText);
        }
Ejemplo n.º 26
0
        public bool PacketSend(long UserID, decimal Amount, int Number, string LeaveMessage, int type, string paypassword, out string message)
        {
            var user = userBLL.GetModel(UserID);

            if (user == null)
            {
                message = "账号不存在";
                return(false);
            }

            if (!ValidPassword(user.SecondPassword, paypassword))
            {
                message = "支付密码错误";
                return(false);
            }

            if (user.IsLock == 1)
            {
                message = "账户已冻结,发红包失败";
                return(false);
            }
            int result = packSendBll.PacketSend(UserID, Amount, Number, LeaveMessage, type);

            if (result > 0)
            {
                string  strSendID = result.ToString();
                decimal len       = result.ToString().Length;

                if ((len % 16) != 0)
                {
                    decimal y = len / 16;
                    decimal b = Math.Ceiling(y);
                    int     p = Convert.ToInt32(b * 16);
                    strSendID = result.ToString().PadRight(p);
                }
                message = AESEncrypt.Encrypt(strSendID);
                return(true);
            }
            if (result == -1)
            {
                message = "账户余额不足";
                return(false);
            }
            else if (result == -2)
            {
                message = "红包金额太小了";
                return(false);
            }
            else
            {
                message = "发红包失败";
                return(false);
            }
        }
Ejemplo n.º 27
0
        public static string Package(string jstr)
        {
            string  enstr = AESEncrypt.Encrypt(jstr, key);
            string  md5   = ComMD5.GetMd5Str(jstr);
            JObject obj   = new JObject();

            obj.Add("sign", md5);
            obj.Add("data", enstr);
            string jstring = JsonConvert.SerializeObject(obj);

            return(jstring);
        }
Ejemplo n.º 28
0
        List <ApplyListModel> getResponseDetail(int userId, params int[] state)
        {
            if (!User.Identity.IsAuthenticated)
            {
                return(new List <ApplyListModel>());
            }
            int          uid   = PageValidate.FilterParam(User.Identity.Name);
            ApplyManager dal   = new ApplyManager(db);
            var          query = from bill in db.Reimbursement
                                 join pr in db.Process_Respond on new { code = bill.reimbursement_code, id = uid } equals new{ code = pr.pr_reimbursement_code, id = pr.pr_user_id } into T1
            from respond in T1.DefaultIfEmpty()
            join res in db.Dic_Respond_State on respond.pr_state equals res.drs_state_id into T2
            from resSt in T2.DefaultIfEmpty()
            join user in db.User_Info on bill.r_add_user_id equals user.user_id
            join s in db.Dic_Respond_State on bill.r_bill_state equals s.drs_state_id
            join f in db.Funds on bill.r_funds_id equals f.f_id
            where state.Contains(bill.r_bill_state)
            orderby bill.r_add_date descending
            select new ApplyListModel
            {
                amount            = bill.r_bill_amount,
                reimbursementCode = bill.reimbursement_code,
                state             = bill.r_bill_state,
                strState          = s.drs_state_name,
                time      = bill.r_add_date,
                fundsCode = f.f_code,
                fundsName = f.f_name,
                userName  = user.real_name,
                info      = bill.reimbursement_info,
                userId    = bill.r_add_user_id,
                manager   = respond.pr_user_id,
                myRespond = resSt.drs_state_name
            };

            if (userId > 0)
            {
                query = query.Where(x => x.manager == userId);
            }
            var list = query.ToList();

            if (list != null)
            {
                foreach (var item in list)
                {
                    item.attachmentsCount = dal.getAttachments(item.reimbursementCode, 0).Count();
                    item.contents         = dal.getContents(item.reimbursementCode, 0).ToList();
                    item.userName         = AESEncrypt.Decrypt(item.userName);
                }
            }

            return(list);
        }
Ejemplo n.º 29
0
        //注册 步骤1
        //验证手机号,发短信验证码
        private string RegisterStep1(HttpContext context)
        {
            //string dec_phone = context.Request["phone"] ?? "";
            string message;

            string jsondata = context.Request["data"] ?? "";

            LogHelper.SaveLog("RegisterStep1:" + jsondata, "RegisterStep");
            RegisterModel rModel = null;

            if (jsondata.Length < 24)
            {
                return(ResultJson(ResultType.error, "请输入正确的手机号", ""));
            }

            try
            {
                jsondata = AESEncrypt.Decrypt(jsondata);
                rModel   = JsonConvert.DeserializeObject <RegisterModel>(jsondata);
            }
            catch
            {
                return(ResultJson(ResultType.error, "请输入正确的手机号", ""));
            }
            if (string.IsNullOrEmpty(rModel.phone))
            {
                return(ResultJson(ResultType.error, "请输入正确的手机号", ""));
            }

            UserService userSvc = new UserService();

            if (userSvc.GetPhoneNumber(rModel.phone) > 0)
            {
                return(ResultJson(ResultType.error, "该手机号已注册", ""));
            }

            if (!userSvc.ExistsInviteCode(rModel.invitecode, out message))
            {
                return(ResultJson(ResultType.error, "邀请码无效", ""));
            }

            bool result = userSvc.SendSMS(rModel.phone, "1");

            if (result)
            {
                return(ResultJson(ResultType.success, "验证码已发送", ""));
            }
            else
            {
                return(ResultJson(ResultType.success, "验证码发送失败", ""));
            }
        }
Ejemplo n.º 30
0
        private void btnEncrypt_Click(object sender, EventArgs e)
        {
            //ICryptoTransform transform = provider.CreateEncryptor();
            //byte[] encryptTextBytes = ASCIIEncoding.ASCII.GetBytes(rtbInput.Text.Trim());
            //byte[] encryptBytes = transform.TransformFinalBlock(encryptTextBytes, 0, rtbInput.Text.Length);
            //rtbOutput.Text = encryptText = Convert.ToBase64String(encryptBytes);

            AESEncrypt aes = new AESEncrypt();

            rtbOutput.Text    = encryptText = aes.Encrypt(rtbInput.Text, out key, out InitVector, out pm);
            lbPublicKey.Text  = key;
            lbPrivateKey.Text = InitVector;
        }