blib/lib/PAGI/Utils/SecureCompare.pm

filter: Statementstmt 100% 19 / 19 Branchbran 100% 4 / 4 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 100% 33 / 33 CC 5 SCAR 12.5
CC
5
Cov
100%
secure_compare
5.0
BEGIN
1.0
BEGIN
1.0
CRAP 3.5
« blib/lib/PAGI/Session.pm ↑ Summary lib/PAGI/Test/SSE.pm »
1 package PAGI::Utils::SecureCompare;
2 31 $PAGI::Utils::SecureCompare::VERSION = '0.002002';
3 31 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 31 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 31 ▶use Exporter 'import';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 31 our @EXPORT_OK = qw(secure_compare);
8  
9 19 ▶sub secure_compare {
Subroutine secure_compare: called CC=5 SCAR=16.1
Pod documented
10 19 my ($a, $b) = @_;
11  
12 19 ▶ return 0 unless defined $a && defined $b;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $a and defined $b 3 16 19
Condition100%3/3
defined $a and defined $b
!ll&&!rl&&r
2116
MC/DC100%2/2
defined $a and defined $b
defined $a defined $b
Truth table100%3/3
A and B
A= defined $aB= defined $b
ABresult
0X0
100
111
13 16 ▶ return 0 unless length($a) == length($b);
Branch: 1 branch
BranchTrueFalseTotal
unless length $a == length $b 6 10 16
14  
15 10 my $result = 0;
16 10 for my $i (0 .. length($a) - 1) {
17 2208 $result |= ord(substr($a, $i, 1)) ^ ord(substr($b, $i, 1));
18 }
19 10 return $result == 0;
20 }
21  
22 31 1;
23  
24 __END__
« blib/lib/PAGI/Session.pm ↑ Summary lib/PAGI/Test/SSE.pm »