Wednesday, December 11, 2013

PHP and C#.Net MD5 code mismatch

Are you experiencing the MD5 code mismatch, even though you are using the same string and key in Php and dot net? Of course it does... Since we need to convert the string + key into ASCII bites. You can use the below code in C#.Net to match the MD5 code in php.


               var strKey = "********";
               var strValue = "abcd";

                byte[] asciiBytes = ASCIIEncoding.ASCII.GetBytes(strValue  + strKey);
                byte[] hashedBytes = MD5CryptoServiceProvider.Create().ComputeHash(asciiBytes);
                string hashedString = BitConverter.ToString(hashedBytes).Replace("-", "").ToLower();

1 comment:

  1. This comment has been removed by a blog administrator.

    ReplyDelete

Please include your thoughts/suggestion to make it as a better blog. If you find it useful, Please update with your valuable comments, so that others can use it.