Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

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 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\""
Comment on Win32 md5sum tool
Select or Download Code

Back to Snippets Section

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2014-10-22 08:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (114 votes), past polls