Note that there are some explanatory texts on larger screens.

plurals
  1. POC# MD5 Hash results not expected result
    text
    copied!<p>I've tried every example I can find on the web but I cannot get my .NET code to produce the same MD5 Hash results from my VB6 app.</p> <p>The VB6 app produces identical results to this site: <a href="http://www.functions-online.com/md5.html" rel="nofollow noreferrer">http://www.functions-online.com/md5.html</a></p> <p>But I cannot get the same results for the same input in C# (using either the MD5.ComputeHash method or the FormsAuthentication encryption method)</p> <p>Please help!!!!</p> <p>As requested, here is some code. This is pulled straight from MSDN:</p> <pre><code> public string hashString(string input) { // Create a new instance of the MD5CryptoServiceProvider object. MD5 md5Hasher = MD5.Create(); // Convert the input string to a byte array and compute the hash. byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input)); // Create a new Stringbuilder to collect the bytes // and create a string. StringBuilder sBuilder = new StringBuilder(); // Loop through each byte of the hashed data // and format each one as a hexadecimal string. for (int i = 0; i &lt; data.Length; i++) { sBuilder.Append(data[i].ToString("x2")); } // Return the hexadecimal string. return sBuilder.ToString(); } </code></pre> <p>My test string is: </p> <p>QWERTY123TEST</p> <p>The results from this code is:</p> <pre><code>8c31a947080131edeaf847eb7c6fcad5 </code></pre> <p>The result from Test MD5 is:</p> <pre><code>f6ef5dc04609664c2875895d7da34eb9 </code></pre> <p>Note: The result from the TestMD5 is what I am expecting</p> <p>Note: I've been really, really stupid, sorry - just realised I had the wrong input. As soon as I hard-coded it, it worked. Thanks for the help</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload