blib/lib/Crypt/RIPEMD160.pm

filter: Statementstmt 100% 48 / 48 Branchbran 91.6% 11 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 100% 4 / 4 totaltotal 98.6% 73 / 74 CC 7 SCAR 9.2
CC
7
Cov
98%
addfile
5.0
hash
2.0
hexhash
2.0
CRAP 2.5
↑ Summary blib/lib/Crypt/RIPEMD160/MAC.pm »
1 package Crypt::RIPEMD160;
2  
3 7 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 7 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 7 our $VERSION = '0.14';
7  
8 7 ▶use XSLoader;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 7 XSLoader::load('Crypt::RIPEMD160', $VERSION);
10  
11 7 ▶use base 'Digest::base';
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 #package RIPEMD160; # Package-Definition like in Crypt::IDEA
14  
15 #use strict;
16 7 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 sub addfile
19 15 ▶{
Subroutine addfile: called CC=5 SCAR=16.1
Pod documented
20 7 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
21 15 my ($self, $handle) = @_;
22 15 my ($package, $file, $line) = caller;
23 15 my ($data);
24  
25 15 ▶ if (!ref($handle)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $handle) 2 13 15
26 2 ▶ $handle = $package . "::" . $handle unless ($handle =~ /(\:\:|\')/);
Branch: 1 branch
BranchTrueFalseTotal
unless $handle =~ /(\:\:|\')/ 0 2 2
27 }
28 15 binmode($handle);
29 15 my $n;
30 15 ▶ while ($n = read($handle, $data, 8192)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n = read($handle, $data, 8192)) 11 15 26
31 11 $self->add($data);
32 }
33 15 ▶ croak "addfile read failed: $!" unless defined $n;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $n 2 13 15
34 13 return $self;
35 }
36  
37 sub hexdigest
38 45 ▶{
Subroutine hexdigest: called CC=1 SCAR=0.0
Pod documented
39 45 my ($self) = shift;
40 45 my ($tmp);
41  
42 45 $tmp = unpack("H*", ($self->digest()));
43 45 return(substr($tmp, 0,8) . " " . substr($tmp, 8,8) . " " .
44 substr($tmp,16,8) . " " . substr($tmp,24,8) . " " .
45 substr($tmp,32,8));
46 }
47  
48 sub hash
49 55 ▶{
Subroutine hash: called CC=2 SCAR=6.9
Pod documented
50 55 my($self, $data) = @_;
51  
52 55 ▶ if (ref($self)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) { } 1 54 55
53 1 $self->reset();
54 } else {
55 54 $self = Crypt::RIPEMD160->new;
56 }
57 55 $self->add($data);
58 55 $self->digest();
59 }
60  
61 sub hexhash
62 37 ▶{
Subroutine hexhash: called CC=2 SCAR=6.9
Pod documented
63 37 my($self, $data) = @_;
64  
65 37 ▶ if (ref($self)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) { } 2 35 37
66 2 $self->reset();
67 } else {
68 35 $self = Crypt::RIPEMD160->new;
69 }
70 37 $self->add($data);
71 37 $self->hexdigest();
72 }
73  
74 7 1;
75 __END__
↑ Summary blib/lib/Crypt/RIPEMD160/MAC.pm »