print "1..2\n";
use strict;
-use Digest::MD5 qw(md5 md5_hex);
+use Digest::MD5 qw(md5 md5_hex md5_base64);
#
# This is the output of: 'md5sum MD5.pm MD5.xs'
EOT
}
+my $B64 = 1;
+eval { require MIME::Base64; };
+if ($@) {
+ print $@;
+ print "# Will not test base64 methods\n";
+ $B64 = 0;
+}
+
my $testno = 0;
use File::Spec;
}
$file = File::Spec->catfile($path, $last);
my $md5bin = pack("H*", $md5hex);
+ my $md5b64;
+ if ($B64) {
+ $md5b64 = MIME::Base64::encode($md5bin, "");
+ chop($md5b64); chop($md5b64); # remove padding
+ }
my $failed;
if (digest_file($file, 'digest') ne $md5bin) {
$failed++;
}
+ if ($B64 && digest_file($file, 'b64digest') ne $md5b64) {
+ print "$file: Bad b64digest\n";
+ $failed++;
+ }
+
my $data = cat_file($file);
if (md5($data) ne $md5bin) {
print "$file: md5() failed\n";
print "$file: md5_hex() failed\n";
$failed++;
}
+ if ($B64 && md5_base64($data) ne $md5b64) {
+ print "$file: md5_base64() failed\n";
+ $failed++;
+ }
if (Digest::MD5->new->add($data)->digest ne $md5bin) {
print "$file: MD5->new->add(...)->digest failed\n";
print "$file: MD5->new->add(...)->hexdigest failed\n";
$failed++;
}
+ if ($B64 && Digest::MD5->new->add($data)->b64digest ne $md5b64) {
+ print "$file: MD5->new->add(...)->b64digest failed\n";
+ $failed++;
+ }
my @data = split //, $data;
if (md5(@data) ne $md5bin) {