I wrote a function that takes the file URL as a parameter and returns the MD5 hash of this file.
The hash generated by this function (in the development environment) corresponds to the hash generated by a third-party tool for the same file.
But when it was deployed in my client QA environment, this function returns different values ββevery time the function is called.
I did some google events and found that the problem might be caused by dev. the server is 64 bits and the QA server is 32 bits. Since I do not have access to my client servers, I deployed it to another 32-bit server and found that the hashes match even on a 32-bit server (does the function work as expected?).
I also considered this question .
here is the function i wrote:
public static String GetMD5HashFromFile(String url) { String response = String.Empty; HttpWebRequest aRequest = (HttpWebRequest)WebRequest.Create(url); using (HttpWebResponse aResponse = (HttpWebResponse)aRequest.GetResponse()) { MD5 md5 = new MD5CryptoServiceProvider(); byte[] retVal = md5.ComputeHash(aResponse.GetResponseStream()); response = "MD5:" + BitConverter.ToString(retVal).Replace("-", string.Empty); } return response; }
My questions; what can cause this function to return different values? Is there a problem in my function?
Awad maharoof
source share