aspose file tools
The moose likes Java in General and the fly likes Regarding checksum calculation Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Regarding checksum calculation" Watch "Regarding checksum calculation" New topic
Author

Regarding checksum calculation

Naveen Koneti
Greenhorn

Joined: Apr 27, 2007
Posts: 13
Hi in my project we are calculating the checksum using MD5 algorithm.The problem is the order of updation of the message digest is changing with this I am getting the different checksum for the same data.Is there any way to get same checksum irrespective of order of addition to the message digest.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12271
    
    1
If you are getting different checksums, SOMETHING is different - either in the data or the way you are doing the checksums.

What do you mean about "the order of updation of the message digest"? You can't expect MD5 to give the same result with different order of data items - only the simplest checksum algorithms would do that.

I suppose you could calculate a message digest for each independent data item and find a way to combine them that does not depend on the order.

Bill


Java Resources at www.wbrogden.com
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 16695
    
  19

You can't expect MD5 to give the same result with different order of data items - only the simplest checksum algorithms would do that.


A *checksum* algorithm will actually do that -- meaning take the sum and check it. Add all the characters together to form the checksum. This algorithm will not care about order since addition doesn't care about order.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Regarding checksum calculation
 
Similar Threads
Please clarify
Message Digest
MD5 Digest Problem in Java
Calculate crc checksum md5
MD5 Digest Problem in Java