Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

CheckSum implemantation details for a file

 
Kumar Gaurav
Ranch Hand
Posts: 108
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

In my application i am fetching files from a file server. Now i have to implement CheckSum on the files that will being fetched so that to avoid any data error. Can any one provide me steps in details so as to implement the checksum on file.

Looking forward for suggestions.
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which checksum algorithm? The java.util.zip package has two classes that implement java.util.zip.Checksum: Adler32 and CRC32. They can be calculated as follows:
If you can't use these, perhaps MessageDigest can help you out.
 
Maruthi Janardhan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A common way to do this is to compute and store the MD5 hash of the file on the server before hand. Then compute the hash on the downloaded file. Download the hash stored on the server and match the same.
Look at java.security.MessageDigest class for info on generating MD5 hash for any data.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!