Advertisement
Guest User

Untitled

a guest
Jul 19th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.00 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;
  14. using System.Globalization;
  15. using System.Web.Configuration;
  16.  
  17. namespace WindowsFormsApplication1
  18. {
  19.     public partial class Form3 : Form
  20.     {
  21.         public Form3()
  22.         {
  23.             InitializeComponent();
  24.             poleHeslo.PasswordChar = '*';
  25.         }
  26.  
  27.         private void button1_Click(object sender, EventArgs e)
  28.         {
  29.             FormsAuthentication.Initialize();
  30.             poleJmeno.Text = poleJmeno.Text.ToUpper();
  31.             poleHeslo.Text = poleHeslo.Text.ToUpper();
  32.             string dataForHash = String.Concat(poleJmeno.Text+ ":" +poleHeslo.Text);
  33.             string hashedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(dataForHash, "sha1");
  34.             MySqlCommand cmd = new MySqlCommand();
  35.             string MyConString = "SERVER=localhost;" + "DATABASE=lb_realm;" + "UID=root;" + "PASSWORD=root;";
  36.             MySqlConnection connection = new MySqlConnection(MyConString);
  37.             MySqlCommand command = connection.CreateCommand();
  38.             MySqlDataReader Reader;
  39.             command.CommandText = "SELECT COUNT(id) FROM account WHERE username='" + poleJmeno.Text + "' AND sha_pass_hash='" + hashedPassword + "' ";
  40.             connection.Open();
  41.             Reader = command.ExecuteReader();
  42.             while (Reader.Read())
  43.             {
  44.                 string thisrow = "";
  45.                 for (int i = 0; i < Reader.FieldCount; i++)
  46.                     thisrow += Reader.GetValue(i).ToString() + ",";
  47.             }
  48.             if (neco)
  49.             {
  50.                 Chyba pyco!
  51.             }
  52.             else
  53.             {
  54.                 Vse OK!
  55.             }
  56.             connection.Close();
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement