Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: MD5 checksums for Windows

by Anonymous Monk
on Jan 13, 2015 at 21:02 UTC ( #1113149=note: print w/replies, xml ) Need Help??


in reply to MD5 checksums for Windows

Thanks for sharing!

Just an observation, which may not be relevant, since your script's output format doesn't exactly match that of md5sum (you include the file's size):

md5sum offers a -b switch, which mainly adds the "b" to the fopen call, which "has no effect; the 'b' is ignored on all POSIX conforming systems, including Linux." It also adds an asterisk to the output line to indicate that the binary mode was used, like so:

$ md5sum -b * fb8d98be1265dd88bac522e1b2182140 *foo.txt f83a0aa1f9ca0f7dd5994445ba7d9e80 *bar.txt d6a6bc0db10694a2d90e3a69648f3a03 *quz.txt

But in my experience people usually ignore the -b switch because it has no effect on those systems. On Windows, of course it's a different story, since there, fopen cares about the "b" mode (among other things, "translations involving carriage-return and linefeed characters are suppressed").

Now whether or not this is an issue at all depends on whether there's a Windows MD5 checksumming tool that defaulted to reading files in text mode. But since you're on Windows and you use binmode, if you felt like making your output more similar to that of md5sum, you could consider adding the asterisk to your output.

Replies are listed 'Best First'.
Re^2: MD5 checksums for Windows
by golux (Chaplain) on Jan 14, 2015 at 15:49 UTC
    Thanks for the suggestion!

    I was unaware of the -b switch, and you're right that the output format doesn't match that of md5sum. Since it's a pretty easy fix (less than 10 lines), I'll add a "-c" (compatibility) switch to the program now.

    say  substr+lc crypt(qw $i3 SI$),4,5
      you rock! that's been on my todo list for ages

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1113149]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2022-05-24 11:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (82 votes). Check out past polls.

    Notices?