@@ -1,5 +1,18 @@
Revision history for Perl module Digest::SHA::PurePerl.
+5.92 Sun Jun 1 00:15:44 MST 2014
+ - changes only to Digest::SHA for version 5.92
+
+5.91 Fri May 16 10:21:44 MST 2014
+ - re-established inheritance from Digest::base
+ -- to pick up future Digest enhancements automatically
+ - cleaned up documentation
+
+5.90 Wed May 7 07:57:08 MST 2014
+ - enhanced Makefile.PL to allow 'use warnings'
+ -- automatically reverts to $^W for early Perls
+ - scrubbed Perl code to remove all compiler warnings
+
5.89 Sat Apr 19 05:14:48 MST 2014
- added universal newlines mode ("U") to addfile and shasum
-- based on Python Universal Newlines concept
@@ -1,6 +1,6 @@
--- #YAML:1.0
name: Digest-SHA-PurePerl
-version: 5.89
+version: 5.92
abstract: Perl implementation of SHA-1/224/256/384/512
license: perl
author:
@@ -11,7 +11,7 @@ requires:
provides:
Digest::SHA::PurePerl:
file: lib/Digest/SHA/PurePerl.pm
- version: 5.89
+ version: 5.92
meta-spec:
version: 1.3
url: http://module-build.sourceforge.net/META-spec-v1.3.html
@@ -4,14 +4,51 @@ use strict;
use ExtUtils::MakeMaker;
my $PM = 'lib/Digest/SHA/PurePerl.pm';
+my $SHASUM = 'shasum';
-my %att = (
+ # 'use warnings' if possible, but stay portable
+
+my($use_warnings, @EDITs);
+my $warn_1 = 'BEGIN { $^W = 1 }';
+my $warn_0 = 'BEGIN { $^W = 0 }';
+{
+ eval "require warnings; import warnings";
+ $use_warnings = $@ ? 0 : 1;
+
+ local(@ARGV) = ($PM, $SHASUM);
+ while (<>) {
+ if (
+ (!$use_warnings && /^(use|no) warnings\b/) ||
+ ( $use_warnings && /^\Q$warn_1\E # use warnings\b/) ||
+ ( $use_warnings && /^\Q$warn_0\E # no warnings\b/)) {
+ push @EDITs, $ARGV;
+ close ARGV;
+ }
+ }
+}
+
+if (@EDITs) {
+ local($^I, @ARGV) = ('', @EDITs);
+ while (<>) {
+ if ($use_warnings) {
+ s/^\Q$warn_1\E # (.*)$/$1/;
+ s/^\Q$warn_0\E # (.*)$/$1/;
+ }
+ else {
+ s/^(use warnings\b.*)$/$warn_1 # $1/;
+ s/^(no warnings\b.*)$/$warn_0 # $1/;
+ }
+ print;
+ }
+}
+
+my %attr = (
'NAME' => 'Digest::SHA::PurePerl',
'VERSION_FROM' => $PM,
- 'EXE_FILES' => [ 'shasum' ],
+ 'EXE_FILES' => [ $SHASUM ],
);
-my $MMversion = $ExtUtils::MakeMaker::VERSION || 0;
-$att{NO_META} = 1 unless $MMversion < 6.10_03;
+my $MMversion = $ExtUtils::MakeMaker::VERSION || '0.00_00';
+$attr{NO_META} = 1 if $MMversion ge '6.10_03';
-WriteMakefile(%att);
+WriteMakefile(%attr);
@@ -1,4 +1,4 @@
-Digest::SHA::PurePerl version 5.89
+Digest::SHA::PurePerl version 5.92
==================================
Digest::SHA::PurePerl is a complete implementation of the NIST
@@ -3,36 +3,31 @@ package Digest::SHA::PurePerl;
require 5.003000;
use strict;
+use warnings;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
use Fcntl;
use integer;
use Carp qw(croak);
-$VERSION = '5.89';
+$VERSION = '5.92';
require Exporter;
@ISA = qw(Exporter);
@EXPORT_OK = (); # see "SHA and HMAC-SHA functions" below
-# If possible, inherit from Digest::base
+# Inherit from Digest::base if possible
eval {
require Digest::base;
push(@ISA, 'Digest::base');
};
-*addfile = \&_Addfile;
-*hexdigest = \&_Hexdigest;
-*b64digest = \&_B64digest;
-
# ref. src/sha.c and sha/sha64bit.c from Digest::SHA
my $MAX32 = 0xffffffff;
-my $TWO32 = 4294967296;
my $uses64bit = (((1 << 16) << 16) << 16) << 15;
-
my @H01 = ( # SHA-1 initial hash value
0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476,
0xc3d2e1f0
@@ -309,12 +304,7 @@ my $sha512 = \&_sha512_placeholder;
my $_64bit_code = '
-my $w_flag;
-
-BEGIN {
- $w_flag = $^W; # suppress compiler warnings about
- $^W = 0; # non-portable 64-bit constants
-}
+no warnings qw(portable);
my @K512 = (
0x428a2f98d728ae22, 0x7137449123ef65cd, 0xb5c0fbcfec4d3b2f,
@@ -365,7 +355,7 @@ my @K512 = (
0x963877195940eabd, 0x96283ee2a88effe3, 0xbe5e1e2553863992,
0x2b0199fc2c85b8aa, 0x0eb72ddc81c52ca2);
-BEGIN { $^W = $w_flag } # restore prior warning state
+use warnings;
sub _c_SL64 { my($x, $n) = @_; "($x << $n)" }
@@ -564,6 +554,7 @@ sub _shawrite {
my($bitstr, $bitcnt, $self) = @_;
return(0) unless $bitcnt > 0;
no integer;
+ my $TWO32 = 4294967296;
if (($self->{lenll} += $bitcnt) >= $TWO32) {
$self->{lenll} -= $TWO32;
if (++$self->{lenlh} >= $TWO32) {
@@ -850,7 +841,7 @@ sub digest {
$rsp;
}
-sub _Hexdigest {
+sub hexdigest {
my $self = shift;
_shafinish($self);
my $rsp = _shahex($self);
@@ -858,7 +849,7 @@ sub _Hexdigest {
$rsp;
}
-sub _B64digest {
+sub b64digest {
my $self = shift;
_shafinish($self);
my $rsp = _shabase64($self);
@@ -887,10 +878,9 @@ sub clone {
my $self = shift;
my $copy = _shadup($self) or return;
bless($copy, ref($self));
- return($copy);
}
-*reset = \&new;
+BEGIN { *reset = \&new }
sub add_bits {
my($self, $data, $nbits) = @_;
@@ -924,22 +914,24 @@ sub _addfile {
$self;
}
-my $_can_T_filehandle;
+{
+ my $_can_T_filehandle;
-sub _istext {
- local *FH = shift;
- my $file = shift;
+ sub _istext {
+ local *FH = shift;
+ my $file = shift;
- if (! defined $_can_T_filehandle) {
- local $^W = 0;
- my $istext = eval { -T FH };
- $_can_T_filehandle = $@ ? 0 : 1;
- return $_can_T_filehandle ? $istext : -T $file;
+ if (! defined $_can_T_filehandle) {
+ local $^W = 0;
+ my $istext = eval { -T FH };
+ $_can_T_filehandle = $@ ? 0 : 1;
+ return $_can_T_filehandle ? $istext : -T $file;
+ }
+ return $_can_T_filehandle ? -T FH : -T $file;
}
- return $_can_T_filehandle ? -T FH : -T $file;
}
-sub _Addfile {
+sub addfile {
my ($self, $file, $mode) = @_;
return(_addfile($self, $file)) unless ref(\$file) eq 'SCALAR';
@@ -1464,9 +1456,6 @@ Like I<digest>, this method is a read-once operation. Call
I<$sha-E<gt>clone-E<gt>hexdigest> if it's necessary to preserve
the original digest state.
-This method is inherited if L<Digest::base> is installed on your
-system. Otherwise, a functionally equivalent substitute is used.
-
=item B<b64digest>
Returns the digest encoded as a Base64 string.
@@ -1475,9 +1464,6 @@ Like I<digest>, this method is a read-once operation. Call
I<$sha-E<gt>clone-E<gt>b64digest> if it's necessary to preserve
the original digest state.
-This method is inherited if L<Digest::base> is installed on your
-system. Otherwise, a functionally equivalent substitute is used.
-
It's important to note that the resulting string does B<not> contain
the padding characters typical of Base64 encodings. This omission is
deliberate, and is done to maintain compatibility with the family of
@@ -1593,9 +1579,8 @@ The author is particularly grateful to
Gunnar Wolf
Adam Woodbury
-"who by trained skill rescued life from such great billows and such thick
-darkness and moored it in so perfect a calm and in so brilliant a light"
-- Lucretius
+"Believe it I don't."
+- Torvic Drewmel
=head1 COPYRIGHT AND LICENSE
@@ -1,11 +1,11 @@
-#!perl -w
+#!perl
## shasum: filter for computing SHA digests (ref. sha1sum/md5sum)
##
## Copyright (C) 2003-2014 Mark Shelor, All Rights Reserved
##
- ## Version: 5.89
- ## Sat Apr 19 05:14:48 MST 2014
+ ## Version: 5.92
+ ## Sun Jun 1 00:15:44 MST 2014
## shasum SYNOPSIS adapted from GNU Coreutils sha1sum. Add
## "-a" option for algorithm selection,
@@ -13,6 +13,11 @@
## "-0" option for reading bit strings, and
## "-p" option for portable digests (to be deprecated).
+use strict;
+use warnings;
+use Fcntl;
+use Getopt::Long;
+
my $POD = <<'END_OF_POD';
=head1 NAME
@@ -96,11 +101,7 @@ L<Digest::SHA::PurePerl>.
END_OF_POD
-use strict;
-use Fcntl;
-use Getopt::Long;
-
-my $VERSION = "5.89";
+my $VERSION = "5.92";
sub usage {
my($err, $msg) = @_;
@@ -28,14 +28,9 @@ my @privfcns = ();
if ($MODULE eq "Digest::SHA") {
@privfcns = qw(
- Addfile
- B64digest
- Hexdigest
- shaopen
- shaclose
+ newSHA
shainit
sharewind
- shadup
shawrite
);
}