Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Security.Cryptography;
- // in Future TODO:
- // * MD5-hashing password of users;
- // * SQL-users, -logins;
- // * create users in Windows-Forms;
- namespace gild
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Form2 f2 = new Form2();
- string log, pass;
- string username=null, code=null;
- SqlConnection conn = new SqlConnection("Data Source=USER12\\SQLEXPRESS;Initial Catalog=testdata;Integrated Security=True;");
- conn.Open();
- SqlCommand cmd = new SqlCommand("select * from testdata.dbo.logins where mode='true'", conn);
- SqlDataReader reader = cmd.ExecuteReader();
- while (reader.Read())
- {
- username = (string)reader[0];
- code = (string)reader[1];
- log = username.ToString();
- pass = code.ToString();
- // * * * * * * * * * *
- // * gethash
- MD5 md5Hasher = MD5.Create();
- byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(textBox2.Text));
- StringBuilder sBuilder = new StringBuilder();
- for (int i = 0; i < data.Length; i++)
- {
- sBuilder.Append(data[i].ToString("x2"));
- }
- string hashkey = sBuilder.ToString();
- // * ending gethash
- // * * * * * * * * * *
- // * verifyhash
- StringComparer comparer = StringComparer.OrdinalIgnoreCase;
- if (0 == comparer.Compare(hashkey, pass))
- {
- ...блабла ...еще дописываю )))
- }
Advertisement
Add Comment
Please, Sign In to add comment