in reply to Digest::MD5::md5_hex giving different values on different machines
To further your cause for information, it might help if you showed Perl/Digest::MD5 and md5sum producing different results. Eg. c&p the shell output.
That would show which combination is producing the wrong results.
Given sisyphus' recent problems with using integers on 64-bit platforms, one possibility is the conversion of the 128-bit integer to hex there has issues.
Another possibility is that you aren't binmodeing the file before reading it. A more common mistake on win32, but with the advent of unicode, maybe that is affecting the results?
Example: The first perl command doesn't binmode the file, the second does:
C:\test>perl -MDigest::MD5=md5_hex -wle"print md5_hex( do{local $/; <> } )" 1Mx4096.db 22502b12bc292ae0a0aa1f4a33942662 C:\test>perl -MDigest::MD5=md5_hex -wle"open I, '<:raw', $ARGV[ 0 ]; print md5_hex(do{local $/; <I>})" 1M +x4096.db 66bff1dfd44db7d4402171056d494b2d C:\test>md5sum 1Mx4096.db 66bff1dfd44db7d4402171056d494b2d *1Mx4096.db
Update: As ikegami alludes to below, in the light of Using ":raw" layer in open() vs. calling binmode(), whether it's broken documentation or a bug in PerlIO, it seems that you need '<:raw:perlio' to achieve the same as binmode via open, which is important if performance is a consideration.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Digest::MD5::md5_hex giving different values on different machines
by ikegami (Patriarch) on Jun 20, 2007 at 17:10 UTC | |
by BrowserUk (Patriarch) on Jun 20, 2007 at 17:36 UTC |