Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace TexByte
- {
- public partial class Form2 : Form
- {
- public Form2()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string password = textBox2.Text;
- string mySalt = BCrypt.Net.BCrypt.GenerateSalt();
- var start = DateTime.UtcNow;
- var hashed = BCrypt.Net.BCrypt.HashPassword(password, mySalt);
- var end = DateTime.UtcNow;
- Console.WriteLine("hash length is {0} chars", hashed.Length);
- Console.WriteLine("Processing time is {0} with workFactor {1}", end - start, mySalt);
- Console.WriteLine("Hashed password: {0} ", hashed);
- Console.WriteLine("correct password {0}", BCrypt.Net.BCrypt.Verify("021495", hashed));
- Console.WriteLine("incorrect password {0}", BCrypt.Net.BCrypt.Verify("PASSWORd", hashed));
- MySqlConnection connection = new MySqlConnection("datasource=localhost;port=3306;Initial Catalog='login';username=root;password=password");
- MySqlDataAdapter adapter;
- DataTable table = new DataTable();
- adapter = new MySqlDataAdapter("SELECT `username`, `password` FROM `members` WHERE `username` = '" + textBox1.Text + "' AND `password` = '" + password + "'", connection);
- adapter.Fill(table);
- if (table.Rows.Count <= 0)
- {
- MessageBox.Show("Invalid Username or Password", "MySQL Login",
- MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- else
- {
- MessageBox.Show("Connection to database successful", "MySQL Login",
- MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- }
- }
- private void Form2_Load(object sender, EventArgs e)
- {
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement