[ale] md5 checksum

Mike Fletcher fletch at phydeaux.org
Wed Jun 30 16:07:57 EDT 1999


>>>>> "Lisa" == Lisa Chiang <chiang at nwisgw3.ic.ornl.gov> writes:

    Lisa> I see this sort of message on many packages: Here is the md5
    Lisa> checksum of the fixed package, please verify these before
    Lisa> installing the new package:

    Lisa> How do I do this?  This isn't the gnu cksum tool is it?

	On my RedHat 6 box, I've got /usr/bin/md5sum:


godzilla:~ 1002> md5sum /etc/hosts
8cc8bea1fc59f70ce4590bf2fd48f3f3  /etc/hosts
godzilla:~ 1003> rpm -qf `which md5sum`
textutils-1.22-9


	Or if you've got the perl MD5 module installed you could use
the following:


#!/usr/bin/perl
use strict;
use FileHandle qw(:DEFAULT);
use MD5 ();
unless( scalar(@ARGV) > 0 ) {
  print STDERR "usage: $0 [file [file ...]]\n";
  exit 1;
}
my $md5 = MD5->new;
foreach( @ARGV ) {
  $md5->reset;
  my $cur = FileHandle->new( $_ );
  unless( $cur ) {
    print STDERR "Can't open $_: $!\n";
    next;
  }
  $md5->addfile( $cur );
  print "MD5 ($_) = ", $md5->hexdigest, "\n";
}
exit 0;
__END__

-- 
Fletch                |                                            __`'/|
fletch at phydeaux.org   |       "I drank what?" -- Socrates          \ o.O'
678 443-6239(w)       |                                            =(___)=
                      |                                               U






More information about the Ale mailing list