Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using MySql.Data;
- using MySql.Data.MySqlClient;
- using System.Security.Cryptography;
- using System.Web.Security;
- using System.Security;
- using System.Globalization;
- namespace WindowsFormsApplication1
- {
- public partial class Form3 : Form
- {
- public Form3()
- {
- InitializeComponent();
- poleHeslo.PasswordChar = '*';
- }
- private void button1_Click(object sender, EventArgs e)
- {
- FormsAuthentication.Initialize();
- //string hashedpwd = String.Concat(poleJmeno.Text, poleHeslo.Text);
- //string hashedPwds = FormsAuthentication.HashPasswordForStoringInConfigFile(hashedpwd, "sha1");
- poleJmeno.Text = poleJmeno.Text.ToUpper(new CultureInfo("en-US", false));
- poleHeslo.Text = poleHeslo.Text.ToUpper(new CultureInfo("en-US", false));
- string dataForHash = String.Concat(poleJmeno.Text, ":");
- string dataForHash2 = String.Concat(dataForHash, poleHeslo.Text);
- string hashedPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(dataForHash2, "sha1");
- string hashedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(poleHeslo.Text, "sha1");
- MySqlCommand cmd = new MySqlCommand();
- string MyConString = "SERVER=localhost;" + "DATABASE=lb_realm;" + "UID=root;" + "PASSWORD=root;";
- MySqlConnection connection = new MySqlConnection(MyConString);
- MySqlCommand command = connection.CreateCommand();
- MySqlDataReader Reader;
- command.CommandText = "SELECT COUNT(id) FROM account WHERE username='" + poleJmeno.Text + "' AND sha_pass_hash='" + hashedPwd + "' ";
- connection.Open();
- Reader = command.ExecuteReader();
- while (Reader.Read())
- {
- string thisrow = "";
- for (int i = 0; i < Reader.FieldCount; i++)
- thisrow += Reader.GetValue(i).ToString() + ",";
- listBox1.Items.Add(thisrow);
- }
- connection.Close();
- poleTest.Text = hashedPwd.ToLower();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement