ghost ghost

ghost ghost

  • NA
  • 1
  • 1.5k

C# wpf bcrypt verification via sql server table

May 30 2016 3:30 AM
  1. private void UserInputKeyDown(object sender, KeyEventArgs e)  
  2. {  
  3.  if (e.Key == Key.Enter) //only accepts enter key  
  4.  {  
  5.   string dbconnection = ConfigurationManager.ConnectionStrings["OverwatchDatabase"].ConnectionString;  
  6.   SqlConnection connection = new SqlConnection(dbconnection);  
  7.   connection.Open();  
  8.   if (connection.State == ConnectionState.Open)  
  9.   {  
  10.    MessageBox.Show("You have been successfully connected to the database!");  
  11.    SqlCommand Password_Hash = new SqlCommand("SELECT Password_Hash" + "From dbo.Authorized_Personnel", connection); //Password_Hash is the column name and Authorized_Personnel is the tables name    
  12.    bool Authenticate = BCrypt.Net.BCrypt.Verify(UserInput.Password, Password_Hash);  //UserInput.Password is the password box on my wpf application  
  13.    if (Authenticate == true)  
  14.    {  
  15.     MessageBox.Show("Authentication Successful");  
  16.     connection.Close(); //closes the connection to database  
  17.     mainscreen = new MainScreen();  
  18.     mainscreen.Show();  
  19.     this.Close();  
  20.    }  
  21.    else  
  22.    {  
  23.     MessageBox.Show("Authentication Failed");  
  24.     Application.Current.Shutdown();  
  25.    }  
  26.   }  
  27.   else  
  28.   {  
  29.     MessageBox.Show("Connection failed.");  
  30.   }  
  31.  }  
  32. }  
I'm having trouble authenticating against my sql server with bcrypt if anyone can help and explain what going on that would very much appreciated  
 
 its throwing an error at the moment saying cannot convert system.dat.sqlclinet.sqlcommand to string
 

Answers (1)