Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.66 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using MySql.Data;
  10. using MySql.Data.MySqlClient;
  11. using System.Security.Cryptography;
  12. using System.Web.Security;
  13. using System.Security.Cryptography.SHA1;
  14.  
  15. namespace WindowsFormsApplication1
  16. {
  17.     public partial class Form3 : Form
  18.     {
  19.         public Form3()
  20.         {
  21.             InitializeComponent();
  22.             poleHeslo.PasswordChar = '*';
  23.         }
  24.  
  25.         private void button1_Click(object sender, EventArgs e)
  26.         {
  27.             FormsAuthentication.Initialize();
  28.             string hashedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(poleHeslo.Text, "sha1");
  29.             MySqlCommand cmd = new MySqlCommand();
  30.             string MyConString = "SERVER=localhost;" + "DATABASE=lb_realm;" + "UID=root;" + "PASSWORD=root;";
  31.             MySqlConnection connection = new MySqlConnection(MyConString);
  32.             MySqlCommand command = connection.CreateCommand();
  33.             MySqlDataReader Reader;
  34.             command.CommandText = "SELECT COUNT(id) FROM account WHERE username='" + poleJmeno.Text + "' AND sha_pass_hash='" + hashedPassword + "' ";
  35.             connection.Open();
  36.             Reader = command.ExecuteReader();
  37.             while (Reader.Read())
  38.             {
  39.                 string thisrow = "";
  40.                 for (int i = 0; i < Reader.FieldCount; i++)
  41.                     thisrow += Reader.GetValue(i).ToString() + ",";
  42.                 listBox1.Items.Add(thisrow);
  43.             }
  44.             connection.Close();
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement