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\""
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.