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;
- using System.Web.Configuration;
- namespace WindowsFormsApplication1
- {
- public partial class Form3 : Form
- {
- public Form3()
- {
- InitializeComponent();
- poleHeslo.PasswordChar = '*';
- }
- private void button1_Click(object sender, EventArgs e)
- {
- FormsAuthentication.Initialize();
- poleJmeno.Text = poleJmeno.Text.ToUpper();
- poleHeslo.Text = poleHeslo.Text.ToUpper();
- string dataForHash = String.Concat(poleJmeno.Text+ ":" +poleHeslo.Text);
- string hashedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(dataForHash, "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='" + hashedPassword + "' ";
- connection.Open();
- Reader = command.ExecuteReader();
- while (Reader.Read())
- {
- string thisrow = "";
- for (int i = 0; i < Reader.FieldCount; i++)
- thisrow += Reader.GetValue(i).ToString() + ",";
- }
- if (neco)
- {
- Chyba pyco!
- }
- else
- {
- Vse OK!
- }
- connection.Close();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement