Quantcast
Channel: Common Language Runtime Internals and Architecture forum
Viewing all articles
Browse latest Browse all 1710

.Net's MD5CryptoServiceProvider().ComputeHash and Java's similar algorithm returns diff values

$
0
0

 

Hi,

          I am stuck up with an issue while verifyng files downloaded from our Portal. The portal is used to distribute softwares to the end users and off-late, we had developed a Java Applet based Download Manager to manage huge downloads with resume capability. Then we moved on to implement the MD5 Checksum to verify the fiel integrity.

 

         The Applet based download manager generates a checksum value after downloading the entire file from the server. It then verifies this value with the value generated on the server side. (Client side is done in Java; Server side in .Net). For downloads which were completed in on go without pausing & resuming, the generated value on client side and server side matches perfectly. But any download which was paused & then resumed gives an altogether different value of Checksum on the client and server side. But importantly the paused/resumed and merged file works perfectly altough the checksum values are different.

 

Server Side code for Checksum Generation

 

using

(FileStream fstream = newFileStream(txtFile.Text.Trim(), FileMode.Open))

{

Byte[] hash = newMD5CryptoServiceProvider().ComputeHash(fstream);

//CONVERT THE BYTE ARRAY TO A PRINTABLE STRING.

StringBuilder sb = newStringBuilder(32);

foreach (byte hex in hash)

sb.Append(hex.ToString(

"X2"));

txtValue.Text = sb.ToString().ToUpper();

}

 

        If the issue is due to the improper merging of the files on the client side via the applet, then the file is not supposed to function properly! but that is not the case.

        Can someone provide some leads as to what the issue might be? and as to why the .Net generated checksum value is different for files which were downloaded in parts and merged?

        

        While resuming a download in the Applet, we append the bytes to the Random Access File and set seek to the actual size of the partially downloaded file.

 

        Any help in this regard would be greatly appreciated!!

       

 

 

 


Viewing all articles
Browse latest Browse all 1710

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>