+2002-12-27 Gisle Aas <gisle@ActiveState.com>
+
+ Release 2.21
+
+ Minor tweaks sync up with bleadperl:
+ - VMS optimizer tweaks to the Makefile.PL
+ - MacOS support
+ - Added alignment test
+
+ Added example to the MD5 POD that shows how to calculate the
+ digest of Unicode strings.
+
+
+
2002-05-05 Gisle Aas <gisle@ActiveState.com>
Release 2.20
use strict;
use vars qw($VERSION @ISA @EXPORT_OK);
-$VERSION = '2.20'; # $Date: 2002/05/06 05:15:09 $
+$VERSION = '2.21'; # $Date: 2002/12/28 05:30:03 $
require Exporter;
*import = \&Exporter::import;
print Digest::MD5->new->addfile(*FILE)->hexdigest, " $file\n";
+Perl 5.8 support Unicode characters in strings. Since the MD5
+algorithm is only defined for strings of bytes, it can not be used on
+strings that contains chars with ordinal number above 255. The MD5
+functions and methods will croak if you try to feed them such input
+data:
+
+ use Digest::MD5 qw(md5_hex);
+
+ my $str = "abc\x{300}";
+ print md5_hex($str), "\n"; # croaks
+ # Wide character in subroutine entry
+
+What you can do is calculate the MD5 checksum of the UTF-8
+representation of such strings. This is achieved by filtering the
+string through encode_utf8() function:
+
+ use Digest::MD5 qw(md5_hex);
+ use Encode qw(encode_utf8);
+
+ my $str = "abc\x{300}";
+ print md5_hex(encode_utf8($str)), "\n";
+ # 8c2d46911f3f5a326455f0ed7a8ed3b3
+
=head1 SEE ALSO
L<Digest>,
use ExtUtils::MakeMaker;
my @extra;
+@extra = (DEFINE => "-DU32_ALIGNMENT_REQUIRED") unless free_u32_alignment();
-unless ($Config{d_u32align}) {
- @extra = (DEFINE => "-DU32_ALIGNMENT_REQUIRED")
- if !($Config{'byteorder'} eq '1234' ||
- $Config{'byteorder'} eq '4321');
-}
-my @optimize = ();
if ($^O eq 'VMS') {
if (defined($Config{ccname})) {
if (grep(/VMS_VAX/, @INC) && ($Config{ccname} eq 'DEC')) {
# VAX compiler optimizer even as late as v6.4 gets stuck
- @optimize = ("OPTIMIZE","/Optimize=(NODISJOINT)");
+ push(@extra, OPTIMIZE => "/Optimize=(NODISJOINT)");
}
}
}
+
WriteMakefile(
'NAME' => 'Digest::MD5',
'VERSION_FROM' => 'MD5.pm',
MAN3PODS => {}, # Pods will be built by installman.
@extra,
'dist' => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
- @optimize
);
exit;
+
+
+sub free_u32_alignment
+{
+ return 0 if $Config{d_u32align};
+ return 1 if $Config{'byteorder'} eq '1234' || $Config{'byteorder'} eq '4321';
+ return 0;
+}
BEGIN {
- chdir 't' if -d 't';
- @INC = '../lib';
+ if ($ENV{PERL_CORE}) {
+ chdir 't' if -d 't';
+ @INC = '../lib';
+ }
}
# Test that md5 works on unaligned memory blocks
use strict;
use Digest::MD5 qw(md5 md5_hex md5_base64);
-#
-# This is the output of: 'md5sum Changes README MD5.pm MD5.xs rfc1321.txt'
-#
-my $EXPECT;
-
# To update the EBCDIC section even on a Latin 1 platform,
# run this script with $ENV{EBCDIC_MD5SUM} set to a true value.
# (You'll need to have Perl 5.7.3 or later, to have the Encode installed.)
# also have the $ENV{PERL_CORE} set to a true value.)
# Similarly, to update MacOS section, run with $ENV{MAC_MD5SUM} set.
+my $EXPECT;
if (ord "A" == 193) { # EBCDIC
$EXPECT = <<EOT;
-b362148b17a451f0d81e0ebb2487756e Changes
+36158997c99f2e1396ee40ddc4634a40 Changes
5a591a47e8c40fe4b78c744111511c45 README
-3157e2d2e27dacddea7c54efddc32520 MD5.pm
+770a5ef28ab15e66355639f21152afb0 MD5.pm
4850753428db9422e8e5f97b401d5a13 MD5.xs
276da0aa4e9a08b7fe09430c9c5690aa rfc1321.txt
EOT
} elsif ("\n" eq "\015") { # MacOS
$EXPECT = <<EOT;
-cc90a85f89b397341f97c9279640fbf5 Changes
-127952946201e6afc19eb41250c56871 README
-d87ec77c963d27198b7427156167a5b3 MD5.pm
-5be7049479ea47d7c257dabcae835720 MD5.xs
-f9a35714ee1d1d0c5a3a80f4dbea956a rfc1321.txt
+e68b13fe9edf36fe13551bf410b7a745 Changes
+3519f3d02c7c91158f732f0f00064657 README
+4113db8afad83eb7c01f1bf2c53e66ee MD5.pm
+1be293491bba726810f8e87671ee0328 MD5.xs
+754b9db19f79dbc4992f7166eb0f37ce rfc1321.txt
EOT
} else {
+ # This is the output of: 'md5sum Changes README MD5.pm MD5.xs rfc1321.txt'
$EXPECT = <<EOT;
-0106b67df0dbf9f4d65e9fc04907745b Changes
+e68b13fe9edf36fe13551bf410b7a745 Changes
3519f3d02c7c91158f732f0f00064657 README
-88c35ca46c7e8069fb5ae00c091c98d6 MD5.pm
+4113db8afad83eb7c01f1bf2c53e66ee MD5.pm
1be293491bba726810f8e87671ee0328 MD5.xs
754b9db19f79dbc4992f7166eb0f37ce rfc1321.txt
EOT
local $/; # slurp
open(FILE, $file) or die "Can't open $file: $!";
- # For PerlIO (Perl 5.8.0 and later) in case of UTF-8 locales.
- eval { binmode(FILE, ":bytes"); };
+ # For PerlIO in case of UTF-8 locales.
+ eval 'binmode(FILE, ":bytes")' if $] >= 5.008;
my $tmp = <FILE>;
close(FILE);