Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


MD5 HashByte  .NET , SQL

Posted on 2008-11-10
Medium Priority
Last Modified: 2013-12-17
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

Question by:joschramm
1 Comment

Accepted Solution

joschramm earned 0 total points
ID: 22920654
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.

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…

577 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question