Fog Creek Software
Discussion Board




MD5 - How do I use this to Compare?

Hi:

I have two jars - I would like to see if these jars are the same.

I rtemeber hearing a while back that it is possible to use MD5 to compare jars and evaluate if they are the same - is this possible and how could I do this?

I checked MD5 under google - it talks about MD5 hash, I am not sure if they are the same thing.

Don Quixote
Monday, June 07, 2004

Take an MD5 hash of each file, compare the hashes. If the hashes are the same, the files are the same.

Philo

Philo
Monday, June 07, 2004

Hi Philo:

I am a novice at this - how do I take an MD5 hash of a jar?

Thanks,

DQ

Don Quixote
Monday, June 07, 2004

Under unix:

md5 <filename>

Rhys Keepence
Monday, June 07, 2004

Of course it's not an absolute guarantee they're the same. There's a roughly one in 2**128 (340 billion billion billion billion) chance of a false match. But that wouldn't keep me awake at night.

Tom H
Monday, June 07, 2004

If you're opening one and then reading the entire file to calculate a hash, and then opening another to read the entire file to calculate a hash, it might be easier to just compare the files directly. First check that the size is the same (to save unnecessary steps), and if it is then iterate through.

Hashes are usually used when you're comparing a file against a database lookup or a known value (such as how online file distributions tell you the hash of an authentic downloaded binary), not to directly compare two present files.

Dennis Forbes
Monday, June 07, 2004

Search for "md5sum" if you just want to use it. If you want to implement it, search for "rfc 1321" instead.

Holger
Tuesday, June 08, 2004

http://support.microsoft.com/default.aspx?scid=kb;en-us;841290

Just me (Sir to you)
Tuesday, June 08, 2004

I wrote a simple (UNIX) command-line program that takes the name of the file and the expected MD5sum and tells you if they are equal. It's very rough-and-ready, but if you want it, let me know.

C Rose
Tuesday, June 08, 2004

codeproject.com has a number of examples of md5 hash classes, if you are using windows.

Jim Howard
Tuesday, June 08, 2004

"I have two jars - I would like to see if these jars are the same."

You realize, of course, that a jar file is just a zip file.  And that if you put the entries into a zip file in a different order you'll end up with archives that match but don't have the same exact byte arrangment.  Generating a single MD5 checksum per jar file then won't match.  So you really should be testing if each of the archived class files (or whatevers in your jar) match, and not the wrapper jar file itself.

5v3n
Tuesday, June 08, 2004

> I wrote a simple (UNIX) command-line program that takes the name of the file and the expected MD5sum and tells you if they are equal. It's very rough-and-ready, but if you want it, let me know.

Why not use "md5sum --check"?

_
Tuesday, June 08, 2004

>> I have two jars - I would like to see if these jars are the same.

Can I weigh them for you? By hand?

.
Friday, June 11, 2004

Google for "Colin Plumb MD5" to obtain a public domain library that you can embed into a C/C++ program.

DavidJones
Sunday, June 13, 2004

I think that for Windows users the GUI utility may be more handy - http://www.accuhash.com :).

Irnis Haliullin
Tuesday, August 17, 2004

*  Recent Topics

*  Fog Creek Home