Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

Win32 md5sum tool

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

Description: 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 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.

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
} else {
    Win32::MsgBox("Could not read file $filename\nDoes it exist?", MB_
+ICONSTOP, "md5sum");

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");

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\command]
@="c:\\projects\\md5sum\\md5sum.exe \"%1\""
Comment on Win32 md5sum tool
Select or Download Code

Back to Snippets Section

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (19)
As of 2015-10-13 12:36 GMT
Find Nodes?
    Voting Booth?

    Does Humor Belong in Programming?

    Results (304 votes), past polls