| 1 | package Digest; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 5 | |||||||||||||||||||||
| 6 | 3 | our $VERSION = "1.20"; | |||||||||||||||||||
| 7 | |||||||||||||||||||||
| 8 | 3 | our %MMAP = ( | |||||||||||||||||||
| 9 | "SHA-1" => [ [ "Digest::SHA", 1 ], "Digest::SHA1", [ "Digest::SHA2", 1 ] ], | ||||||||||||||||||||
| 10 | "SHA-224" => [ [ "Digest::SHA", 224 ] ], | ||||||||||||||||||||
| 11 | "SHA-256" => [ [ "Digest::SHA", 256 ], [ "Digest::SHA2", 256 ] ], | ||||||||||||||||||||
| 12 | "SHA-384" => [ [ "Digest::SHA", 384 ], [ "Digest::SHA2", 384 ] ], | ||||||||||||||||||||
| 13 | "SHA-512" => [ [ "Digest::SHA", 512 ], [ "Digest::SHA2", 512 ] ], | ||||||||||||||||||||
| 14 | "SHA3-224" => [ [ "Digest::SHA3", 224 ] ], | ||||||||||||||||||||
| 15 | "SHA3-256" => [ [ "Digest::SHA3", 256 ] ], | ||||||||||||||||||||
| 16 | "SHA3-384" => [ [ "Digest::SHA3", 384 ] ], | ||||||||||||||||||||
| 17 | "SHA3-512" => [ [ "Digest::SHA3", 512 ] ], | ||||||||||||||||||||
| 18 | "HMAC-MD5" => "Digest::HMAC_MD5", | ||||||||||||||||||||
| 19 | "HMAC-SHA-1" => "Digest::HMAC_SHA1", | ||||||||||||||||||||
| 20 | "CRC-16" => [ [ "Digest::CRC", type => "crc16" ] ], | ||||||||||||||||||||
| 21 | "CRC-32" => [ [ "Digest::CRC", type => "crc32" ] ], | ||||||||||||||||||||
| 22 | "CRC-CCITT" => [ [ "Digest::CRC", type => "crcccitt" ] ], | ||||||||||||||||||||
| 23 | "RIPEMD-160" => "Crypt::RIPEMD160", | ||||||||||||||||||||
| 24 | ); | ||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | 7 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=9 SCAR=22.0
Pod
documented
| |||||||||||||||||||||
| 27 | 7 | shift; # class ignored | |||||||||||||||||||
| 28 | 7 | my $algorithm = shift; | |||||||||||||||||||
| 29 | 7 | ▶ | my $impl = $MMAP{$algorithm} || do { | ||||||||||||||||||
|
Condition66%2/3
$Digest::MMAP{$algorithm} || do {
$algorithm =~ s/\W+//g;
"Digest::$algorithm"
}
MC/DC0%0/2
$Digest::MMAP{$algorithm} || do {
$algorithm =~ s/\W+//g;
"Digest::$algorithm"
}
$Digest::MMAP{$algorithm}
do {
$algorithm =~ s/\W+//g;
"Digest::$algorithm"
}
Truth table66%2/3
A || B
A= $Digest::MMAP{$algorithm}B= do {
$algorithm =~ s/\W+//g;
"Digest::$algorithm"
}
| |||||||||||||||||||||
| 30 | 6 | $algorithm =~ s/\W+//g; | |||||||||||||||||||
| 31 | 6 | "Digest::$algorithm"; | |||||||||||||||||||
| 32 | }; | ||||||||||||||||||||
| 33 | 7 | ▶ | $impl = [$impl] unless ref($impl); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 34 | 7 | local $@; # don't clobber it for our caller | |||||||||||||||||||
| 35 | 7 | my $err; | |||||||||||||||||||
| 36 | 7 | for (@$impl) { | |||||||||||||||||||
| 37 | 9 | my $class = $_; | |||||||||||||||||||
| 38 | 9 | my @args; | |||||||||||||||||||
| 39 | 9 | ▶ | ( $class, @args ) = @$class if ref($class); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 40 | 3 | ▶ | no strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 41 | 9 | ▶ | unless ( exists ${"$class\::"}{"VERSION"} ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 42 | 7 | my $pm_file = $class . ".pm"; | |||||||||||||||||||
| 43 | 7 | $pm_file =~ s{::}{/}g; | |||||||||||||||||||
| 44 | 7 | eval { | |||||||||||||||||||
| 45 | 7 | local @INC = @INC; | |||||||||||||||||||
| 46 | 7 | ▶ | pop @INC if $INC[-1] eq '.'; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 47 | 7 | require $pm_file | |||||||||||||||||||
| 48 | }; | ||||||||||||||||||||
| 49 | 7 | ▶ | if ($@) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 50 | 3 | ▶ | $err ||= $@; | ||||||||||||||||||
|
Condition66%2/3
$err ||= $@
MC/DC0%0/2
$err ||= $@
$err
$@
Truth table66%2/3
A ||= B
A= $errB= $@
| |||||||||||||||||||||
| 51 | 3 | next; | |||||||||||||||||||
| 52 | } | ||||||||||||||||||||
| 53 | } | ||||||||||||||||||||
| 54 | 6 | return $class->new( @args, @_ ); | |||||||||||||||||||
| 55 | } | ||||||||||||||||||||
| 56 | 1 | die $err; | |||||||||||||||||||
| 57 | } | ||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | 3 | our $AUTOLOAD; | |||||||||||||||||||
| 60 | |||||||||||||||||||||
| 61 | 1 | ▶ | sub AUTOLOAD { | ||||||||||||||||||
|
Subroutine
AUTOLOAD: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 62 | 1 | my $class = shift; | |||||||||||||||||||
| 63 | 1 | my $algorithm = substr( $AUTOLOAD, rindex( $AUTOLOAD, '::' ) + 2 ); | |||||||||||||||||||
| 64 | 1 | $class->new( $algorithm, @_ ); | |||||||||||||||||||
| 65 | } | ||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | 3 | 1; | |||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | __END__ | ||||||||||||||||||||