How to generate a short eight character md5 signature in perl, similar to what is done by the OpenSSL utility "openssl -x509 -hash -noout < certfile" The shorter signature increases the odds of collisions, but takes up less space.
use Digest::MD5;
my $fh;
if (@ARGV) {
my $file = shift;
open $fh, $file or die "error: could not open $file: $!\n";
binmode $fh;
} else {
$fh = *STDIN;
}
printf "%08x\n", unpack "N", Digest::MD5->new->addfile($fh)->digest;