title: matching a text input with a hashed value in MySQL
body: <p>I have a winform c# application. It connects to MySQL remotely and matches passwords stored in the MySQL database table . The passwords are stored using SHA1. I have stored a default value : "mypassword" and hashed it using SHA1.</p>
  
  <p>When the application runs, first the user is asked to enter the password. For this if i use the below mentioned function then it generates a different hash string when compared to the one generated by MySQL SHA1 function. How to match the values? Please help.</p>
  
  <pre><code>  public static string HashCode(string str)
          {
              string rethash = "";
              try
              {
  
                  System.Security.Cryptography.SHA1 hash = System.Security.Cryptography.SHA1.Create();
                  System.Text.ASCIIEncoding encoder = new System.Text.ASCIIEncoding();
                  byte[] combined = encoder.GetBytes(str);
                  hash.ComputeHash(combined);
                  rethash = Convert.ToBase64String(hash.Hash);
              }
              catch (Exception ex)
              {
                  string strerr = "Error in HashCode : " + ex.Message;
              }
              return rethash;
          }
      }
  </code></pre>
  
  <p>Am calling it like this : </p>
  
  <pre><code> string hashedvalue =  HashCode("mypassword");
              MessageBox.Show("The hashed value is : " + hashedvalue);
  </code></pre>
  
  <p>Is hashing of both are different?</p>