MD5 HashByte .NET , SQL

Hi All,

i am Developing a web Project with a login site and i need to Convert my Password in an MD5 HashCode, the password is in my MSSQL DATABASE in an "master.dbo.fn_varbintohexstr(HashBytes('MD5',Password))"  Converted.
and in my .Net VisualStudio i retrieve this Password and compare it with the Logins Password Texfield wich i Converted in MD5 before i compare . my Problem is that the Hashcode in SQL is different that the hashcode in .NET althought i write the same Password. can anyone tell why and how i solved my Problem.
thanks in advanced..
//here is the Method wich i Convert the Textfiel Password in MD5 .NET     
 
   public static string GetMD5Hash(string TextToHash)
        {
            //Prüfen ob Daten übergeben wurden.
            if (string.IsNullOrEmpty(TextToHash))
            {
                return string.Empty;
            }
            MD5 md5 = new MD5CryptoServiceProvider();
            UTF8Encoding encoder = new UTF8Encoding();
            byte[] textToHash = encoder.GetBytes(TextToHash);
            byte[] result = md5.ComputeHash(textToHash);
            return BitConverter.ToString(result);
        }

Open in new window

joschrammAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

joschrammAuthor Commented:
hi, i found the solution.
my Password from the Database give me an HashByte with '0x' in the beginning of the code and in my .Net give me without it, thats why it wasnt equal.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.