Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6044703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:02:30+00:00 2026-05-23T07:02:30+00:00

I have a winform c# application. It connects to MySQL remotely and matches passwords

  • 0

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.

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.

  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;
        }
    }

Am calling it like this :

 string hashedvalue =  HashCode("mypassword");
            MessageBox.Show("The hashed value is : " + hashedvalue);

Is hashing of both are different?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T07:02:31+00:00Added an answer on May 23, 2026 at 7:02 am

    SHA-1 hash from MySQL is a hex-encoded string, while C# gives Base64-encoded string, so try this

    rethash = BitConverter.ToString(hash.Hash).Replace("-", "");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a winform application that connects to a database on our corporate
i am using 3 tier architecture in my winform application so i have static
I am creating C# winforms application, which connects to the Database. Because I have
I have a WinForm application using a FlowLayoutPanel that displays .TIFF files that have
I have Winforms application written in C# which connects to a SQL Server Database.
I have a C# form application that connects to a electronic device using the
i have Winform application who run all the files within listbox, i am using
I have a winform application that contains a c# webbrowser control.Webbrower control load a
I have a winform application which contains a window resizable but one requirement is
I have an c# winform application that runs under a local account but needs

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.