Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Win32 md5sum tool

by meredith (Friar)
on May 28, 2003 at 12:06 UTC ( [id://261276]=CUFP: print w/replies, xml ) Need Help??

Here's a quickie, it is meant to be added to the context menu for all files using the registry patch at the bottom (You want to change the run path to wherever you put md5sum.pl). So anyway, you right click a file, choose MD5 Sum, and there is a dialog box to tell you that the md5sum is in the clipboard. It doesn't cover all the bases (comparing sums), but you can usually do that with your eyes. I used perlapp to get rid of the console window, if you're wondering.
---8<----- md5sum.pl
#!perl use warnings; use Digest::MD5; use FileHandle; use File::Basename; use Win32; use Win32::Clipboard; my $md5 = Digest::MD5->new; my $filename = $ARGV[0]; my $fh = new FileHandle; if ($fh->open("< $filename")) { binmode $fh; # we'll just assume $md5->addfile($fh); } else { Win32::MsgBox("Could not read file $filename\nDoes it exist?", MB_ +ICONSTOP, "md5sum"); exit; } my $digest = $md5->hexdigest; my $CLIP = Win32::Clipboard(); $CLIP->Set($digest) or do { Win32::MsgBox("Could not set the clipboard. Things are strange her +e.", MB_ICONSTOP, "md5sum"); exit; }; my ($basename,undef,undef) = fileparse($filename); Win32::MsgBox("The MD5 sum for file \'$basename\' is now in the clipbo +ard:\n\n$digest", MB_ICONINFORMATION, "md5sum");


---8<----- md5sum.reg
Windows Registry Editor Version 5.00 [HKEY_CLASSES_ROOT\*\shell\MD5 Sum] [HKEY_CLASSES_ROOT\*\shell\MD5 Sum\command] @="c:\\projects\\md5sum\\md5sum.exe \"%1\""

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2024-04-25 11:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found