Even if I knew where to start, I'd probably write something half as efficient as others have already done, so why try? Does anyone have/know a fast, easy to implement function/library for calculating MD5sums on files?
Even if I knew where to start, I'd probably write something half as efficient as others have already done, so why try? Does anyone have/know a fast, easy to implement function/library for calculating MD5sums on files?
Last edited by Viper187; 06-24-2008 at 09:46 AM.
There's a program in the GNU coreutils called "md5sum". I'm not sure what it uses, but it's quite fast. You could execute that program if you're using Linux.
Ah, here's the source for it, I think. http://www.koders.com/c/fid3D64E21C0...A6C6A9EB4.aspx
Not sure if that's useful or not . . . Googling for "md5sum c library" shows at least one other implementation.
dwk
Seek and ye shall find. quaere et invenies.
"Simplicity does not precede complexity, but follows it." -- Alan Perlis
"Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
"The only real mistake is the one from which we learn nothing." -- John Powell
Other boards: DaniWeb, TPS
Unofficial Wiki FAQ: cpwiki.sf.net
My website: http://dwks.theprogrammingsite.com/
Projects: codeform, xuni, atlantis, nort, etc.
What's wrong with using OpenSSL's md5 functions?
http://cr.yp.to/2004-494/gaim/0.81-src/md5.c
You'll need to create your own .h file to provide prototypes. There are only a few functions, so that should be simple enough.
Code://try //{ if (a) do { f( b); } while(1); else do { f(!b); } while(1); //}
I would have thought that there is very little in the md5sum code that is linux specific.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
There's a md5.h here:
http://cr.yp.to/2004-494/gaim/0.81-src/md5.h
I just built that on my Windows machine with. The only two changes I had to make was to include stdio.h in the "TEST" section, and put an "int" in front of the main().Code:gcc -Wall -o md5 md5.c -DTEST
The second teststring doesn't seem to match the md5 value in the comments to the same string - not sure why that is. All the others match. (The second strings produces: 4d52535c7692376e7e7e205940a93ae9)
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
The more I look at this stuff, I think I'd rather use CRC32/64 for this project, if anyone could point me to an easy to use example in C. I don't like the prospect of dealing with all these char arrays of hashes vs a simple array of 32/64 bit integers. The thing I intend to write will recurse subdirectories looking for duplicate files by comparing checksums.
The code that brewbuck posted a link to is pretty straight forward. CRC32 is not much easier, since it also involves a table of pre-computed values.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.