blib/lib/Digest/SHA256.pm

filter: Statementstmt 69.5% 32 / 46 Branchbran 35.7% 5 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 71.4% 5 / 7 Podpod 0.0% 0 / 4 totaltotal 59.1% 42 / 71 CC 8 SCAR 17.2
CC
8
Cov
62%
addfile
12.6
hash
6.0
hexdigest
3.0
CRAP 5.6
↑ Summary _sha256.c »
1 package Digest::SHA256;
2  
3 # SHA256 perl module written by Rafael R. Sevilla
4 # This program is free software; you can redistribute it and/or
5 # modify it under the same terms as Perl itself.
6  
7 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 require Exporter;
11 1 require DynaLoader;
12 1 require AutoLoader;
13  
14 1 @ISA = qw(Exporter AutoLoader DynaLoader);
15 1 @EXPORT = qw();
16 1 $VERSION = '0.01';
17  
18 1 bootstrap Digest::SHA256 $VERSION;
19  
20 sub addfile
21 0 ▶{
Subroutine addfile: not called CC=4 SCAR=25.3
Pod undocumented
22 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
23 0 my ($self, $handle) = @_;
24 0 my ($package, $file, $line) = caller;
25 0 my $data = ' ' x 8192;
26  
27 0 ▶ if (!ref($handle)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $handle) 0 0 0
28 0 ▶ $handle = "$package::$handle" unless ($handle =~ /(\:\:|\')/);
Branch: 1 branch
BranchTrueFalseTotal
unless $handle =~ /(\:\:|\')/ 0 0 0
29 }
30 0 ▶ while (read($handle, $data, 8192)) {
Branch: 1 branch
BranchTrueFalseTotal
if (read $handle, $data, 8192) 0 0 0
31 0 $self->add($data);
32 }
33 }
34  
35 sub hexdigest
36 6 ▶{
Subroutine hexdigest: called CC=3 SCAR=11.0
Pod undocumented
37 6 my ($self) = shift;
38 6 my ($tmp, $str, $i);
39  
40 6 $tmp = unpack("H*", ($self->digest()));
41 6 $str = substr($tmp, 0,8) . " " . substr($tmp, 8,8) . " " .
42 substr($tmp,16,8) . " " . substr($tmp,24,8) . " " .
43 substr($tmp,32,8) . " " . substr($tmp,40,8) . " " .
44 substr($tmp,48,8) . " " . substr($tmp,56,8);
45 6 $i = $self->length();
46 6 ▶ return($str) if ($self->length() == 256);
Branch: 1 branch
BranchTrueFalseTotal
if $self->length == 256 2 4 6
47 4 $str = substr($tmp, 0,16) . " " . substr($tmp,16,16) . " " .
48 substr($tmp,32,16) . " " . substr($tmp,48,16) . " " .
49 substr($tmp,64,16) . " " . substr($tmp,80,16);
50 4 ▶ return($str) if ($self->length() == 384);
Branch: 1 branch
BranchTrueFalseTotal
if $self->length == 384 2 2 4
51 2 $str = substr($tmp, 0,16) . " " . substr($tmp,16,16) . " " .
52 substr($tmp,32,16) . " " . substr($tmp,48,16) . " " .
53 substr($tmp,64,16) . " " . substr($tmp,80,16) . " " .
54 substr($tmp,96,16) . " " . substr($tmp,112,16);
55 2 return($str);
56  
57 }
58  
59 sub hash
60 0 ▶{
Subroutine hash: not called CC=2 SCAR=17.9
Pod undocumented
61 0 my($self, $data) = @_;
62  
63 0 ▶ if (ref($self)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) { } 0 0 0
64 0 $self->reset();
65 } else {
66 0 $self = new Digest::SHA256;
67 }
68 0 $self->add($data);
69 0 $self->digest();
70 }
71  
72 sub hexhash
73 6 ▶{
Subroutine hexhash: called CC=2 SCAR=7.2
Pod undocumented
74 6 my($self, $data) = @_;
75  
76 6 ▶ if (ref($self)) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self) { } 6 0 6
77 6 $self->reset();
78 } else {
79 0 $self = new Digest::SHA256;
80 }
81 6 $self->add($data);
82 6 $self->hexdigest();
83 }
84  
85 1 1;
86 __END__
↑ Summary _sha256.c »