protected override bool OnBeforeSave() { txtPassword.Text = Cryption.Encrypt(txtPassword.Text); txtPassword.DataBindings["Text"].WriteValue(); return(base.OnBeforeSave()); }
private void Verify(string key, string expected) { Cryption subject = new Cryption(key); string actual = subject.EncryptText(expected); Assert.AreEqual(expected, subject.DecryptText(actual)); }
protected void Register_Click(object sender, EventArgs e) { try { LoginReference.Service1Client client = new LoginReference.Service1Client(); if (!Session["generatedString"].Equals(textInput1.Text)) // Comparing input string and random string { Error.Text = "The string entered is incorrect so please try again!"; } else { string response = client.addUser(UserInput.Text, Cryption.Encrypt(PasswordInput.Text), 2); // Adding the user by manipulating XML file if (response.Equals("success")) { // Error.Text = "User has been registered Successfully!"; Session["registration"] = "success"; Response.Redirect("LoginMember"); } else if (response.Equals("exist")) { Error.Text = "Username already exist! Provide a new username"; } else { // Error.Text = "Username or password is incorrect!!"; Error.Text = response; } } } catch (Exception e1) { Error.Text = e1.Message; } }
protected void GoButton_Click(object sender, EventArgs e) { try { LoginReference.Service1Client client = new LoginReference.Service1Client(); string response = client.searchUser(username_input.Text, Cryption.Encrypt(passsword_input.Text), 2); // Check whether user and password are correct by searching in users.xml file if (response.Equals("success")) { HttpCookie mycookies = new HttpCookie("MemberCookieId"); mycookies["Name"] = username_input.Text; // Store username and password in cookies mycookies["Password"] = Cryption.Encrypt(passsword_input.Text); mycookies.Expires = DateTime.Now.AddMonths(6); Response.Cookies.Add(mycookies); Session["username"] = username_input.Text; // Storing username is session so that it could be used in welcome page Session["role"] = "1"; Response.Redirect("MemberPage.aspx"); } else if (response.Equals("unsuccess")) { Error.Text = "Username or password is incorrect!!"; } else { Error.Text = response; } } catch (Exception e1) { Error.Text = e1.Message; } }
protected void btnChangePass_Click(object sender, EventArgs e) { try { SendMailEntities db = new SendMailEntities(); User user = db.Users.FirstOrDefault(x => x.AccountName == Context.User.Identity.Name); if (Cryption.Decrypt(user.Password) == txt_pass_old.Value) { if (txt_pass_new.Value == txt_pass_new_repeat.Value) { user.Password = Cryption.Encrypt(txt_pass_new.Value); db.SaveChanges(); lbl_failure.Text = ""; string message = "Bạn đã thay đổi mật khẩu thành công"; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + message + "');", true); } else { lbl_failure.Text = "Mật khẩu nhập lại không đúng!"; } } else { lbl_failure.Text = "Mật khẩu cũ của bạn không đúng!"; } } catch (Exception v_e) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + v_e + "');", true); } }
public ActionResult Login(LoginModels _login) { if (ModelState.IsValid) //validating the user inputs { var loginUser = new dto_login { nombre = string.Empty, pass = Cryption.Encrypt(_login.Password, ConfigurationManager.AppSettings["claveEncriptacion"]), vendedor = string.Empty, cod_agente = _login.Cedula.ToString(), estado = string.Empty, correo = string.Empty }; //Manager.ClientPostRequest(loginUser, AppSettings.urlApi, AppSettings.controladorLogin); //Manager.SendRequestAsync(AppSettings.urlApi , AppSettings.controladorLogin, loginUser); ManagerUser mang = new ManagerUser(); var dto_retorno = mang.Login(loginUser); // var result = await _signInManager.PasswordSignInAsync(Input.Cedula, Input.Password, Input.RememberMe, lockoutOnFailure: true); if (dto_retorno.Any()) {
private bool PublicationsOnChange(int ObjectHashCode) { using (SHA256 sha256 = SHA256.Create()) { string hashedcode = Cryption.Encrypt(sha256, Convert.ToBase64String(BitConverter.GetBytes(ObjectHashCode))); return(Mysqldb.Update($"update tables_onchange set Value='{hashedcode}' where TableName='publications'")); } }
public void ProcessRequest(HttpContext context) { context.Response.Clear(); string id = context.Request.QueryString["ScopeId"]; Cryption objCryption = new Cryption(); long lngScopeId = long.Parse(id); GenerateSpreadsheetforGroupedWorksheet(lngScopeId, context); }
public async void DecryptAsyncShouldDecryptdata() { var data = "Hello World PGPCore!"; var TestdataFileName = @"..\..\..\TestData\content_encrypted.pgp"; string decryptedContent = await File.ReadAllTextAsync(TestdataFileName); //Act var sut = new Cryption(); var result = await sut.DecryptAsync(decryptedContent); //Assert result.Should().Equals(data); }
public static string EditUserAdminData(string username, string password, string givenname, string familyname, string auth, int roleid, int id) { String NewPwd = Cryption.GetEncryptedSHA256(password); var data = BAL.AddEdit_UserAdmin(username, NewPwd, givenname, familyname, auth, roleid, id, 2); HttpContext context = HttpContext.Current; context.Response.Filter = new GZipStream(context.Response.Filter, CompressionMode.Compress); HttpContext.Current.Response.AppendHeader("Content-Encoding", "gzip"); HttpContext.Current.Response.ContentType = "application/json charset=utf-8"; return(data); }
public JsonResult RoboCassaReq() { var mrh_login = "******"; var mrh_pass1 = "Yw9KvwRPwXw1iRh5Ep10"; // номер заказа // number of order var inv_id = 321; // описание заказа // order description var inv_desc = "oplata v1"; // сумма заказа // sum of order var out_summ = "999.96"; // тип товара // code of goods var shp_item = "10"; // предлагаемая валюта платежа // default payment e-currency var in_curr = ""; // язык // language var culture = "ru"; // кодировка // encoding var encoding = "utf-8"; // формирование подписи // generate signature var crc = Cryption.GetMd5Hash(mrh_login + ":" + out_summ + ":" + inv_id + ":" + mrh_pass1 + ":Shp_item=" + shp_item); var IsTest = 1; string requrl = "'https://auth.robokassa.ru/Merchant/PaymentForm/FormFLS.js?MrchLogin="******"&OutSum=" + out_summ + "&InvId=" + inv_id + "&IncCurrLabel=" + in_curr + "&Desc=" + inv_desc + "&SignatureValue=" + crc + "&Shp_item=" + shp_item + "&Culture=" + culture + "&Encoding=" + encoding + "&IsTest =" + IsTest + "'"; Response.Redirect(requrl, true); return(Json(0)); }
private static void sendEmailSchedule() { using (SendMailEntities db = new SendMailEntities()) { List<TempScheduleSendEmail> list_temp = new List<TempScheduleSendEmail>(); List<LogSendEmail> lst_logEndEmail = new List<LogSendEmail>(); TempScheduleSendEmail latest = db.TempScheduleSendEmails.Where(x => x.IDUser == mGlobal.UserID).ToList().OrderBy(m => m.TimeSchedule).FirstOrDefault(); list_temp = db.TempScheduleSendEmails.Where(x => x.TimeSchedule == latest.TimeSchedule && x.IDUser == mGlobal.UserID).ToList(); Int64 idEmailOwn = Int64.Parse(list_temp[0].IDEmailOwn.ToString()); EmailOwn emailOwn = db.EmailOwns.FirstOrDefault(x => x.ID == idEmailOwn); foreach (var item in list_temp) { //get contact Contact contact = db.Contacts.FirstOrDefault(x => x.Email == item.Email); //save log send email LogSendEmail log = new LogSendEmail(); if (item.IDCampaign != null) { log.CampaignID = item.IDCampaign; } log.ContactID = contact.ContactID; log.StatusSend = true; log.IDEmailOwn = emailOwn.ID; log.TypeServiceUsed = "STPM"; log.UserID = mGlobal.UserID; log.Subject = item.Subject; log.Body = item.ContentEmail; log.TimeSend = (DateTime)item.TimeSchedule; lst_logEndEmail.Add(log); STPMService.SendMail(emailOwn.Email , Cryption.Decrypt(emailOwn.Password) , item.Email , item.Subject , item.ContentEmail); } //db.EmailContents.AddRange(lst_emailContent); db.LogSendEmails.AddRange(lst_logEndEmail); db.TempScheduleSendEmails.RemoveRange(list_temp); db.SaveChanges(); } }
public static void ReadDataClient() { PreferencesManager <MailPref> myMailPref = new PreferencesManager <MailPref>("", null); MailPref mailPref = myMailPref.ReadPreference(); if (mailPref != null) { FromDisplay = mailPref.Name; FromAddress = mailPref.EmailAddress; UseDefaultCredentials = mailPref.UseDefaultCredentials; Host = mailPref.Host; Port = mailPref.Port; UserName = mailPref.UserName; Password = Cryption.Decrypt(mailPref.Password); EnableSsl = mailPref.EnableSsl; } }
protected void Button1_Click(object sender, EventArgs e) { HttpCookie myCookies = new HttpCookie("myKeyie"); string fLocation1 = Path.Combine(Request.PhysicalApplicationPath, @"App_Data\Member.xml"); bool redirect = false; if (File.Exists(fLocation1)) { FileStream fS = new FileStream(fLocation1, FileMode.Open, FileAccess.Read, FileShare.Read); XmlDocument xd = new XmlDocument(); xd.Load(fS); XmlNode node = xd; XmlNodeList children = node.ChildNodes; foreach (XmlNode child in children.Item(1)) { if (TextBox1.Text == child.FirstChild.InnerText) { string decryptedPassword = Cryption.Decrypt(child.LastChild.InnerText); if (TextBox2.Text == decryptedPassword) { FormsAuthentication.SetAuthCookie(TextBox1.Text, createPersistentCookie: false); Session["Username"] = TextBox1.Text; Session["Password"] = TextBox2.Text; myCookies["Username"] = TextBox1.Text; myCookies["Password"] = TextBox2.Text; myCookies.Expires = DateTime.Now.AddMonths(6); Response.Cookies.Add(myCookies); Result.Text = "Successful"; Response.Redirect("Member/MemberPage.aspx"); redirect = true; break; } } } if (redirect == false) { Result.Text = "Fail"; } fS.Close(); } }
public static String DES(Cryption crypt, String hexString, String key, String iv = "0000000000000000") { DESCryptoServiceProvider des = new DESCryptoServiceProvider(); ICryptoTransform desencrypt = null; des.Key = hex2Bytes(key); des.IV = hex2Bytes(iv); des.Padding = PaddingMode.Zeros; byte[] cryptData = hex2Bytes(hexString); if (crypt == Cryption.Encrypt) { desencrypt = des.CreateEncryptor(); } else { desencrypt = des.CreateDecryptor(); } return(BitConverter.ToString( desencrypt.TransformFinalBlock(cryptData, 0, cryptData.Length)).Replace("-", string.Empty)); }
protected void BtnDecrypt_Click(object sender, EventArgs e) { try { string input = TextDecrypt.Text; string output = ""; if (input != string.Empty) { output = Cryption.Decrypt(input); } else { output = "Please enter valid input string"; } LabelDecryptedResult.Text = output; } catch (Exception ex) { LabelDecryptedResult.Text = ex.Message; } }
protected void btnLogin_Click(object sender, EventArgs e) { try { int userId = 0; string constr = ConfigurationManager.ConnectionStrings["SendMailConnectionString"].ConnectionString; using (SqlConnection con = new SqlConnection(constr)) { using (SqlCommand cmd = new SqlCommand("Validate_User")) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@AccountName", txt_account.Value); cmd.Parameters.AddWithValue("@Password", Cryption.Encrypt(txt_password.Value)); cmd.Connection = con; con.Open(); userId = Convert.ToInt32(cmd.ExecuteScalar()); con.Close(); } switch (userId) { case -1: lbl_failure.Text = "Tên tài khoản hoặc mật khẩu không chính xác!"; break; default: FormsAuthentication.RedirectFromLoginPage(txt_account.Value, rememberMe.Checked); FormsAuthentication.SetAuthCookie(txt_account.Value, true); Debugger.Log(1, "Login", " " + this.User.Identity.IsAuthenticated); mGlobal.AccountName = this.User.Identity.Name; mGlobal.UserID = userId; break; } } } catch (Exception) { throw; } }
public Connection(String strXmlFilePath, String strKeys) { String strConnectionStringLoc = ""; //Set Keys for Encrypt and Decrypt Cryption.strKeys = ASCIIEncoding.ASCII.GetBytes(strKeys); XmlDocument xdSettings = new XmlDocument(); xdSettings.Load(strXmlFilePath); XmlNode xnConnectionString = xdSettings.SelectSingleNode("/App/DataBase/ConnectionString"); strConnectionStringLoc = "Data Source=" + xnConnectionString.Attributes["DataSource"].Value + ";Initial Catalog=" + xnConnectionString.Attributes["InitialCatalog"].Value + ";Persist Security Info=" + xnConnectionString.Attributes["PersistSecurityInfo"].Value + ";User ID=" + Cryption.Decrypt(xnConnectionString.Attributes["UserID"].Value) + ";Password="******"Password"].Value); this.strConnectionStringPty = strConnectionStringLoc; }
protected void Register_Click(object sender, EventArgs e) { try { LoginReference.Service1Client client = new LoginReference.Service1Client(); if (PasswordInput.Text.Equals("")) { Error.Text = "Password is Empty"; } else if (UserInput.Text.Equals("")) { Error.Text = "Username is Empty"; } else { string response = client.addUser(UserInput.Text, Cryption.Encrypt(PasswordInput.Text), 2); // Adding the user by manipulating XML file if (response.Equals("success")) { XmlDataSource1.XPath = "/users/user"; Error.Text = "User added Successfully!"; } else if (response.Equals("exist")) { Error.Text = "Username already exist! Provide a new username"; } else { // Error.Text = "Username or password is incorrect!!"; Error.Text = response; } } } catch (Exception e1) { Error.Text = e1.Message; } }
protected void loginButton_Click(object sender, EventArgs e) { var user = email.Text.ToString(); var pass = password.Text.ToString(); var NewPwd = Cryption.GetEncryptedSHA256(pass); DataTable dt = BAL.Login(user, NewPwd); if (dt.Rows.Count > 0) { Session["login"] = dt.Rows[0][0].ToString(); Session["role"] = dt.Rows[0][1].ToString(); Session["permissions"] = dt.Rows[0][2].ToString(); Session["permissionscsv"] = uniqPermissions(dt.Rows[0][2].ToString()); Session["UserId"] = dt.Rows[0]["Id"].ToString(); //get permissions from roles table and store it in session if (remember.Checked) { Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(30); Response.Cookies["Password"].Expires = DateTime.Now.AddDays(30); } else { Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(-1); Response.Cookies["Password"].Expires = DateTime.Now.AddDays(-1); } Response.Cookies["UserName"].Value = email.Text.Trim(); Response.Cookies["Password"].Value = password.Text.Trim(); Response.Redirect("default.aspx"); } else { error.Text = "Please Check Email And PassWord"; } }
public override bool OnOk() { if (Cryption.Encrypt(txtOldPwd.Text) != oldPwd) { MessageBox.Show( Properties.Resources.Password_Different, Properties.Resources.Warning, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } if (txtNewPwd.Text != txtConfirmPwd.Text) { MessageBox.Show( Properties.Resources.Password_Different, Properties.Resources.Warning, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } Password = txtNewPwd.Text; return(base.OnOk()); }
protected void btnSendMail_Click(object sender, EventArgs e) { try { using (SendMailEntities db = new SendMailEntities()) { ListEditItem cmbEmailOwnselectedItem = cmbEmailOwn.SelectedItem; ListEditItem cmbcmbContactselectedItem = cmbContact.SelectedItem; ListEditItem cmbcmbCampaignselectedItem = cmbCampaign.SelectedItem; string toEmail = cmbcmbContactselectedItem.GetValue("Email").ToString(); string fromEmail = cmbEmailOwnselectedItem.GetValue("Email").ToString(); string password = Cryption.Decrypt(cmbEmailOwnselectedItem.GetValue("Password").ToString()); Int64 IdEmailOwn = Int64.Parse(cmbEmailOwnselectedItem.GetValue("ID").ToString()); //EmailOwn emailOwn = db.EmailOwns.FirstOrDefault(x => x.ID == IdEmailOwn); LogSendEmail email = new LogSendEmail(); email.Subject = ip_txt_subject.Value; email.Body = txt_content_mail.Value; email.ContactID = Int64.Parse(cmbcmbContactselectedItem.GetValue("ContactID").ToString()); email.UserID = mGlobal.UserID; email.IDEmailOwn = IdEmailOwn; email.CampaignID = Int64.Parse(cmbcmbCampaignselectedItem.GetValue("CampaignID").ToString()); if (radio_service_google.Checked) { email.TypeServiceUsed = mGlobal.GOOGLE; try { GoogleMailService.sendMail("*****@*****.**", createEmail.createMessage(email.Subject , email.Body , fromEmail , toEmail)); email.StatusSend = true; } catch (Exception) { email.StatusSend = false; } } else if (radio_service_stpm.Checked) { email.TypeServiceUsed = mGlobal.STPM; try { STPMService.SendMail(fromEmail , password , toEmail , email.Subject , email.Body); email.StatusSend = true; } catch (Exception) { email.StatusSend = false; } } email.TimeSend = DateTime.Now; db.LogSendEmails.Add(email); db.SaveChanges(); string message = "Gửi email thành công"; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + message + "');", true); } } catch (Exception v_e) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + v_e + "');", true); } }
public void ProcessRequest(HttpContext context) { ManagementService m_ManagementService = new ManagementService(); m_ManagementService.SQLConnection = ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString; if (context.Request.Files.Count > 0) { try { Cryption m_Cryption = new Cryption(); Int32 m_UserID = 0; bool isValid = true; if (string.IsNullOrEmpty(context.Request.Form["UserId"])) { isValid = false; } if (isValid) { if (!Int32.TryParse(m_Cryption.Decrypt(context.Request.Form["UserId"], m_Cryption.cryptionKey), out m_UserID)) { isValid = false; } } if (m_UserID <= 0) { isValid = false; } if (isValid) { UserProfile m_ContactUserProfile = new UserProfile(); m_ContactUserProfile = m_ManagementService.GetUserProfileByUserID(m_UserID); HttpFileCollection files = context.Request.Files; for (int i = 0; i < files.Count; i++) { HttpPostedFile file = files[i]; string filename = String.Format("{0}", DateTime.Now.ToString("yyyyMMddHHmmss")); string extension = System.IO.Path.GetExtension(file.FileName); string filePath = String.Format(@"{0}\images\{1}\{2}{3}", ConfigurationManager.AppSettings["WebProjectPath"], m_ContactUserProfile.Identifier, filename, extension); if (!System.IO.Directory.Exists(String.Format(@"{0}\images\{1}", ConfigurationManager.AppSettings["WebProjectPath"], m_ContactUserProfile.Identifier))) { System.IO.Directory.CreateDirectory(String.Format(@"{0}\images\{1}", ConfigurationManager.AppSettings["WebProjectPath"], m_ContactUserProfile.Identifier)); } using (var binaryReader = new System.IO.BinaryReader(file.InputStream)) { byte[] fileData = binaryReader.ReadBytes(file.ContentLength); System.IO.FileStream wFile = new System.IO.FileStream(filePath, System.IO.FileMode.Create); wFile.Write(fileData, 0, file.ContentLength); wFile.Close(); m_ManagementService.CRUDMobActivity(m_UserID, 0, Convert.ToInt32(context.Request.Form["JobId"]), Convert.ToString(context.Request.Form["Date"]), Convert.ToString(context.Request.Form["Description"]), m_ContactUserProfile.Identifier, filename, extension.Replace(".", ""), fileData, filename, "PhotoUpload"); } } } else { throw new Exception("Invalid User"); } } catch (Exception ex) { m_ManagementService.LogError(ex.Message, ex.StackTrace); context.Response.StatusCode = 400; context.Response.ContentType = "json"; context.Response.Write("{success: 'false', message: '" + ex.Message + "'}"); } } }
public static string GetSenhaDescripto(string senha) { return senha; if (string.IsNullOrEmpty(senha)) return senha; //if (!ConfiguracaoSenha.SenhaEstaCriptografada()) //{ var cry = new Cryption(); senha = cry.DecryptString(senha); //senha = FormsAuthentication.HashPasswordForStoringInConfigFile(senha, "sha1"); //} return senha; }
protected override void OnBeforeEdit() { txtPassword.Text = Cryption.Decrypt(txtPassword.Text); }
public string TryLogin(byte[] data) { byte[] user = new byte[10]; byte[] pass = new byte[10]; Buffer.BlockCopy(data, 1, user, 0, 10); Buffer.BlockCopy(data, 33, pass, 0, 10); int usercnt = 0, passcnt = 0; for (int x = 0; x < 10; x++) { if (user[x] == 00) { break; } if ((int)user[x] > 127) { return("4"); } usercnt++; } for (int x = 0; x < 10; x++) { if (pass[x] == 00) { break; } if ((int)pass[x] > 127) { return("4"); } passcnt++; } string test = Encoding.ASCII.GetString(user, 0, usercnt).ToUpper().Trim(); var test2 = Encoding.ASCII.GetString(pass, 0, passcnt); //SHA1 if (!System.Text.RegularExpressions.Regex.IsMatch(test, @"^[a-zA-Z0-9]+$")) { return("4"); } if (test.Count() < 3 || test2.Count() < 5) { return("4"); } if (handler.HasPlayer(test)) { return("5"); } #if NOSQL return("6" + test + "," + test2); #endif // var info = BinaryIO.LoadName(test); var infos = handler.add.Where(xe => xe.Value.Name == test).FirstOrDefault().Value; if (infos == null) { return("6" + test + "," + test2); } List <string> info = new List <string>(); info.Add(infos.Name); info.Add(infos.Pass); if (info != null && info[0] == test) { if (info[1].Count() <= 10) { if (info[1] != test2) { return("2"); } } else { if (!Cryption.CheckHashPass(info[1], test, test2)) { return("2"); } } return("1" + test + "," + test2); } else { return("6" + test + "," + test2); } }
public void HandleIncoming(Byte[] data) { if (nsa != null) { nsa.AppendPacketIn(data); } PacketReader p = null; switch (data[0]) { case 0x34: // Keep Alive keepalive = Server.tickcount.ElapsedMilliseconds; break; //Identifiy /* case 0x37: * // for (int x = 0; x < 40; x++) * // { * // SendPacket(new CreateSlotMagic(new MagicSpell((byte)(x+81), "Hii", 1, 1, (byte)x, library.MagicType.Casted)).Compile()); * // } * int y = 14; * byte sprite = 0; * for (int x = 0; x < 255; x++) * { * Thread.Sleep(100); * if (x != 0 && x % 19 == 0) * { * y += 3; * x -= 19; * } * // SendPacket(new CreateMonster(new Monster(3, (short)(x+23),(short)y,"village.map", sprite.ToString(), sprite, 0), Serial.NewMobile).Compile()); * sprite++; * } * break;*/ case 0x3A: //find if (player.Map == "Loen") { var slot = data[1] + 40 + (12 * player.BankTab); var itemtofind = World.NewItems.Where(xe => xe.Value.ParSer == player.Serial && xe.Value.InvSlot == slot).FirstOrDefault(); if (itemtofind.Value != null) { if (player.GetFreeSlot() != -1) { SendPacket(new DeleteEntrustSlot((byte)data[1]).Compile()); itemtofind.Value.InvSlot = player.GetFreeSlot(); SendPacket(new AddItemToInventory2(itemtofind.Value).Compile()); } } } break; case 0x36: //Entrust if (player.Map == "Loen") { var itemtoentrust = World.NewItems.Where(xe => xe.Value.ParSer == player.Serial && xe.Value.InvSlot == data[1]).FirstOrDefault(); if (itemtoentrust.Value != null) { SendPacket(new DeleteItemSlot((byte)itemtoentrust.Value.InvSlot).Compile()); itemtoentrust.Value.InvSlot = player.FreeBankSlot; SendPacket(new AddItemToEntrust(itemtoentrust.Value).Compile()); } } break; case 0x35: //sell if (player.Map == "Loen") { var itemtosell = World.NewItems.Where(xe => xe.Value.ParSer == player.Serial && xe.Value.InvSlot == data[1]).FirstOrDefault(); if (itemtosell.Value != null && itemtosell.Value.SellPrice > 0) { player.Gold += (uint)itemtosell.Value.SellPrice; itemtosell.Value.Delete(player); } } break; //Cast // 3D-00-00-01-00-00-00-0A-00-09-00 case 0x3D: case 0x19: case 0x18: if (LKCamelot.Server.tickcount.ElapsedMilliseconds - player.CastSpeed > LastCast) { LastCast = LKCamelot.Server.tickcount.ElapsedMilliseconds; p = new PacketReader(data, data.Count(), true); int spellslot = p.ReadInt16(); if (player.MagicLearned.Count() < spellslot) { return; } int castonid = p.ReadInt32(); short castx = p.ReadInt16(); short casty = p.ReadInt16(); script.spells.Spell castspell = player.MagicLearned.Where(xe => xe.Slot == spellslot).FirstOrDefault(); if (castspell == null) { return; } castHandler.HandleCast(data[0], castspell, player, castonid, castx, casty); } break; //Attack case 0x17: if (LKCamelot.Server.tickcount.ElapsedMilliseconds - player.AttackSpeed > LastAttack) { LastAttack = LKCamelot.Server.tickcount.ElapsedMilliseconds; World.SendToAll(new QueDele(player.Serial, player.Map, new SwingAnimationChar(player.Serial, player.Face).Compile())); combatHandler.HandleMelee(player, data[1]); } break; //NPC Shop case 0x45: var npclook = World.NewNpcs.Where(xe => xe.Key == data[1]).FirstOrDefault(); if (npclook.Value != null) { if (npclook.Value.Name == "Loen") { SendPacket(new SpawnShopGump2(npclook.Value.Gump).Compile()); } if (npclook.Value.Name == "Arnold") { SendPacket(new SpawnShopGump2(npclook.Value.Gump).Compile()); } if (npclook.Value.Name == "Employee") { SendPacket(new SpawnShopGump2(npclook.Value.Gump).Compile()); } if (npclook.Value.Name == "Boy") { SendPacket(new SpawnShopGump2(npclook.Value.Gump).Compile()); } } break; case 0x2B: //2B-03-00-00-00-01-00-04-00-4D-65-6E-75-00 p = new PacketReader(data, data.Count(), true); var npcid = p.ReadInt32(); var buyslot = p.ReadByte(); var npcitself = World.NewNpcs.Where(xe => xe.Key == npcid).FirstOrDefault(); if (npcitself.Value != null) { npcitself.Value.Buy(player, buyslot); } break; //Inventory case 0x00: //use if (data[1] == 0) { return; } var itemu = World.NewItems.Where(xe => xe.Value.m_Parent == player && xe.Value.InvSlot == data[1]).FirstOrDefault(); if (itemu.Value != null) { itemu.Value.Use(player); } break; case 0x20: //drop var item = World.NewItems.Where(xe => xe.Value.m_Parent == player && xe.Value.InvSlot == data[1]).FirstOrDefault(); if (item.Value != null) { item.Value.Drop(player); } break; case 0x1F: //pickup var item1 = World.NewItems.Where(xe => xe.Value.m_Map != null && xe.Value.m_Map == player.Map && xe.Value.Loc.X == player.X && xe.Value.Loc.Y == player.Y) .FirstOrDefault(); if (item1.Value != null) { item1.Value.PickUp(player); } break; case 0x1E: //equip Use // case 0x36: var eitem = World.NewItems.Where(xe => xe.Value.m_Parent == player && xe.Value.InvSlot == data[1]).FirstOrDefault(); if (eitem.Value != null) { if (eitem.Value is script.item.BaseArmor || eitem.Value is script.item.BaseWeapon) { eitem.Value.Equip(player); } if (eitem.Value is script.item.BaseSpellbook) { eitem.Value.Use(player); } if (eitem.Value is script.item.BasePotion) { eitem.Value.Use(player); } } break; case 0x23: //unequip var uitem = World.NewItems.Where(xe => xe.Value.m_Parent == player && xe.Value.InvSlot == (data[1] + 25)).FirstOrDefault(); if (uitem.Value != null) { uitem.Value.Unequip(player, data[1] + 25); } break; case 0x25: //swap items var item11 = World.NewItems.Where(xe => xe.Value.ParSer == player.Serial && xe.Value.InvSlot == data[1]).FirstOrDefault().Value; int sss = 0; if (data.Count() > 3) { sss = data[3]; } var target1 = World.NewItems.Where(xe => xe.Value.ParSer == player.Serial && xe.Value.InvSlot == sss).FirstOrDefault().Value; player.SwapItems(item11, target1, sss); break; case 0x24: //drag,drop var itemdragdrop = World.NewItems.Where(xe => xe.Value.ParSer == player.Serial && xe.Value.InvSlot == data[1]).FirstOrDefault().Value; if (itemdragdrop != null) { p = new PacketReader(data, data.Count(), false); var targetid = p.ReadInt32(); script.item.Item targeti = null; World.NewItems.TryGetValue(targetid, out targeti); if (targeti != null) { string fail = "Refining failed."; string succ = "Refining success."; if ((itemdragdrop is script.item.Zel && targeti is script.item.BaseArmor) || (itemdragdrop is script.item.Dai && targeti is script.item.BaseWeapon)) { if (targeti.TryUpgrade()) { castHandler.CreateMagicEffect(targeti.Loc, targeti.m_Map, 42); SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)succ.Count(), succ).Compile()); SendPacket(new DeleteObject(targeti.m_Serial).Compile()); SendPacket(new CreateItemGround2(targeti, targeti.m_Serial).Compile()); } else { castHandler.CreateMagicEffect(targeti.Loc, targeti.m_Map, 56); SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)fail.Count(), fail).Compile()); } itemdragdrop.Delete(player); } } if (targetid == 4) { if (itemdragdrop.Name == "Promote Life Drug" && AronStage == 4) { AronStage = 1; itemdragdrop.Delete(player); string achat = "[Aron]: Are you ready for the promotion?"; SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)achat.Count(), achat).Compile()); } if (itemdragdrop.Name == "Promote Magic Drug" && AronStage == 4) { AronStage = 2; itemdragdrop.Delete(player); string achat = "[Aron]: Are you ready for the promotion?"; SendPacket(new UpdateChatBox(0xff, 0xff, 1, (short)achat.Count(), achat).Compile()); } } } break; //Chat message case 0x16: p = new PacketReader(data, data.Count(), false); var str = p.ReadString(); var str2 = str.Split(' '); if (Util.ContainsUnicodeCharacter(str)) { var x = 1; } HandleChat(str2, str); break; //Movement case 0x14: player.Face = data[1]; World.SendToAll(new QueDele(player.Serial, player.Map, new ChangeFace(player.Serial, player.Face).Compile())); break; case 0x15: if (Server.tickcount.ElapsedMilliseconds - player.lastmove < 150) { return; } long totalwalk = 0; foreach (var loc in walktrace) { totalwalk += loc; } // if(player.Name == "SIR") // Console.WriteLine(string.Format("{0},{1} {2}", px, py, Server.tickcount.ElapsedMilliseconds)); if (Server.tickcount.ElapsedMilliseconds - player.lastmove > player.m_MoveSpeed) { p = new PacketReader(data, data.Count(), true); player.Face = p.ReadInt16(); var px = p.ReadInt16(); var py = p.ReadInt16(); walktrace.Add(Server.tickcount.ElapsedMilliseconds - player.lastmove); player.lastmove = Server.tickcount.ElapsedMilliseconds; /* * if (walktrace.Count > 3 && totalwalk < 1600) * { * SendPacket(new MoveSpriteWalkChar(player.Serial, player.Face, player.X, player.Y).Compile()); * return; * } * * while (walktrace.Count > 4) * walktrace.Remove(walktrace.ElementAt(0)); */ if (World.Dist2d(new Point2D(px, py), player.m_Loc) > 3) { SendPacket(new MoveSpriteWalkChar(player.Serial, player.Face, player.X, player.Y).Compile()); return; } player.X = px; player.Y = py; World.SendToAll(new QueDele(player.Serial, player.Map, new MoveSpriteWalkChar(player.Serial, player.Face, player.X, player.Y).Compile())); parseFace(); } else { SendPacket(new MoveSpriteWalkChar(player.Serial, player.Face, player.X, player.Y).Compile()); } break; //Stats case 0x2C: player.AddStat(ref player.m_Str); SendPacket(new UpdateCharStats(player).Compile()); break; case 0x2D: player.AddStat(ref player.m_Men); SendPacket(new UpdateCharStats(player).Compile()); break; case 0x2E: player.AddStat(ref player.m_Dex); SendPacket(new UpdateCharStats(player).Compile()); break; case 0x2F: player.AddStat(ref player.m_Vit); SendPacket(new UpdateCharStats(player).Compile()); break; case 0x03: //Login var result = TryLogin(data); switch (result[0]) { case '1': var puser2 = result.Remove(0, 1).Split(','); player = handler.add.Where(xe => xe.Value.Name == puser2[0]).FirstOrDefault().Value; player.client = this; player.loggedIn = true; LoadPlayer(); SendPacket(new CloseLogin().Compile()); break; case '2': SendPacket(new WrongPass().Compile()); break; case '3': SendPacket(new WrongID().Compile()); break; case '4': //invalid chars SendPacket(new WrongID().Compile()); break; case '5': SendPacket(new AlreadyOnline().Compile()); break; case '6': player = new Player(this); player.CreateBeginner(result.Remove(0, 1)); firstlogin = true; LoadPlayer(); player.Pass = Cryption.CreateSaltedSHA256(player.Pass, player.Name); try { handler.add.TryAdd(player.Name, player); var touch = handler.add.Where(xe => xe.Key == player.Name).FirstOrDefault(); touch.Value.client = this; touch.Value.loggedIn = true; // BinaryIO.SavePlayer(player); // World.DBConnect.InsertPlayer(player); } catch { Console.WriteLine("failed to insert new player"); } SendPacket(new CloseLogin().Compile()); break; } break; case 0x49: //delete magic var magdelslot = data[1]; player.DeleteMagic(magdelslot); break; case 0x26: //swap magic if (data.Count() < 4) { player.SwapMagic(data[1], 0); } else { player.SwapMagic(data[1], data[3]); } break; case 0xff: SendPacket(new PlayMusic(1000).Compile()); if (true) //Login { // SendPacket(new CloseLogin().Compile()); // SendPacket(new LoadWorld(1, 0x12, 0x12, new byte[] { 00, 04, 00, 00, 00, 00, 00, 00, 00, 03 }, // 01, 01, 00, 03, 04, 00, 00, // new byte[] { 0x69, 0x70, 0x69, 0x67, 0x6d, 0x79, 0x31, 0x2e, 0x6d, 0x61, 0x70, 00 }).Format()); break; } } }
public JsonResult RoboCassaReq(int tarifid, int tariftype, int kolvomes) { var mrh_login = SettingsManager.robocassaid; var mrh_pass1 = SettingsManager.robopass;//"Yw9KvwRPwXw1iRh5Ep10"; // номер заказа // number of order var utrf = CoreLogic.securityManager.psave_payment(Uinf.CurUserId(Request), tarifid, tariftype, kolvomes); var inv_id = utrf.inv_id; // описание заказа // order description var inv_desc = "oplata v1"; // сумма заказа // sum of order string out_summ = utrf.summ.ToString() + ".00"; // тип товара // code of goods var shp_item = tariftype.ToString(); // предлагаемая валюта платежа // default payment e-currency var in_curr = ""; // язык // language var culture = "ru"; // кодировка // encoding var encoding = "utf-8"; // формирование подписи // generate signature var crc = Cryption.GetMd5Hash(mrh_login + ":" + out_summ + ":" + inv_id + ":" + mrh_pass1); string istets = SettingsManager.robotest; // + ":Shp_item=" + shp_item var IsTest = 1; string requrl = "https://auth.robokassa.ru/Merchant/Index.aspx?isTest=" + istets + "&MerchantLogin="******"&InvId=" + inv_id.ToString() + "&OutSum=" + out_summ + "&SignatureValue=" + crc + "&Culture=ru"; // string requrl = "https://auth.robokassa.ru/Merchant/Index.aspx?isTest=1&MerchantLogin=be24test&InvId=324&OutSum=100.00&SignatureValue=efb982bc1a84e3a196b79f10e2d77048&Culture=ru"; //string requrl = "'https://auth.robokassa.ru/Merchant/PaymentForm/FormFLS.js?MrchLogin="******"&OutSum=" + out_summ + "&InvId=" + inv_id + "&IncCurrLabel=" + in_curr + // "&Desc=" + inv_desc + "&SignatureValue=" + crc + "&Shp_item=" + shp_item + // "&Culture=" + culture + "&Encoding=" + encoding + "&IsTest =" + IsTest + "'"; Response.Redirect(requrl, true); return(Json(0)); }
public void InitializeCryptionTest() { subject = new Cryption(key); }
protected void btnSendListMail_Click(object sender, EventArgs e) { try { SendMailEntities db = new SendMailEntities(); //List<EmailContent> lst_emailContent = new List<EmailContent>(); List <LogSendEmail> lst_logEndEmail = new List <LogSendEmail>(); List <TempSendEmail> lst_TempSendEmail = new List <TempSendEmail>(); ListEditItem cmbEmailOwnselectedItem = cmbEmailOwn.SelectedItem; ListEditItem cmbcmbCampaignselectedItem = cmbCampaign.SelectedItem; Int64 IdEmailOwn = Int64.Parse(cmbEmailOwnselectedItem.GetValue("ID").ToString()); EmailOwn emailOwn = db.EmailOwns.FirstOrDefault(x => x.ID == IdEmailOwn); lst_TempSendEmail = db.TempSendEmails.Where(x => x.IDUser == mGlobal.UserID).ToList(); //email.fromEmail = cmbEmailOwn.Text; //email.passWordSendMail = Cryption.Decrypt(selectedItem.GetValue("Password").ToString()); if (radio_service_google.Checked) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Hiện chưa hỗ trợ service này!" + "');", true); } else if (radio_service_stpm.Checked) { foreach (TempSendEmail item in lst_TempSendEmail) { //get contact Contact contact = db.Contacts.FirstOrDefault(x => x.Email == item.Email); //save log send email LogSendEmail log = new LogSendEmail(); log.CampaignID = Int64.Parse(cmbcmbCampaignselectedItem.GetValue("CampaignID").ToString()); log.ContactID = contact.ContactID; log.Subject = item.Subject; log.Body = item.ContentEmail; //log.EmailID = emailContent.EmailID; log.StatusSend = true; log.IDEmailOwn = IdEmailOwn; log.TypeServiceUsed = mGlobal.STPM; log.UserID = mGlobal.UserID; log.TimeSend = DateTime.Now; lst_logEndEmail.Add(log); STPMService.SendMail(emailOwn.Email , Cryption.Decrypt(emailOwn.Password) , item.Email , item.Subject , item.ContentEmail); } //db.EmailContents.AddRange(lst_emailContent); db.LogSendEmails.AddRange(lst_logEndEmail); db.SaveChanges(); ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + "Gửi thành công!" + "');", true); } } catch (Exception v_e) { ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + v_e + "');", true); // Debugger.Log(1, "Send Mail", "Failed: " + v_e); } }