| 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
Condition100%3/3
defined $a and defined $b
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
| |||||||||||||||||||||||||||||
| 13 | 16 | ▶ | return 0 unless length($a) == length($b); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 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__ | ||||||||||||||||||||||||||||