Put Words into a Variables and Check if it Matches the Data in database

Using the built in crypto classes in .NET can be surprisingly complicated. You need a lot of understanding of what you are doing to get it right and how to work in a secure manner. The choice of algorithm, what cipher mode, key length, block size and understand what salt is and how to use it and also how to hash a password to a proper key are some things you need to deal with. Hopefully, this article will make your life a lot easier.

  1. private void ImageSearch()  
  2. {  
  3.    if (txtSearch.Text.Trim().Equals(""))  
  4.    {  
  5.       //when types nothing  
  6.       txtSearch.Focus();  
  7.       Warning.Text = "Please enter the keyword to search";  
  8.       //display message  
  9.       return;  
  10.    }  
  11.    else  
  12.    {  
  13.       int check = Process.CheckStopWord(txtSearch.Text.Trim());  
  14.       //check if the keyword is stop word  
  15.       if (check == 0)  
  16.       {  
  17.          txtSearch.Focus();  
  18.          Warning.Text = "No stop word found";  
  19.       }  
  20.       else  
  21.       {  
  22.          txtSearch.Focus();  
  23.          Warning.Text = "Found Stop word";  
  24.       }  
  25.    }  
  26. }  
  27. public static int CheckStopWord(string keyword)  
  28. {  
  29.    string check = "0";  
  30.    string query = "SELECT COUNT (stopword) FROM stopwordtb WHERE [stopword] like '" + keyword + "'";  
  31.    //count how many stop word matches the keyword entered, return a string of a number  
  32.    accessDB dbaccess = new accessDB();  
  33.    DataSet ds = dbaccess.queryData(query);  
  34.    DataTable dt = ds.Tables[0];  
  35.    if (dt.Rows[0][0].ToString() == check)  
  36.    {  
  37.       return 0;  
  38.       //keyword != stop word in stopwordtb  
  39.       // begin search in image database - not implemented yet  
  40.    }  
  41.    else  
  42.    {  
  43.       return 1;  
  44.       //keyword = stop word in stopwordtb  
  45.    }  
  46. }