File Coverage

blib/lib/Crypt/Passphrase/Encoder.pm
Criterion Covered Total %
statement 20 22 90.9
branch 2 4 50.0
condition 2 3 66.6
subroutine 6 7 85.7
pod 3 3 100.0
total 33 39 84.6


line stmt bran cond sub pod time code
1             package Crypt::Passphrase::Encoder;
2             $Crypt::Passphrase::Encoder::VERSION = '0.021';
3 7     7   155015 use strict;
  7         15  
  7         251  
4 7     7   36 use warnings;
  7         10  
  7         344  
5              
6 7     7   32 use parent 'Crypt::Passphrase::Validator';
  7         15  
  7         78  
7              
8 7     7   3362 use Crypt::SysRandom;
  7         11367  
  7         1727  
9              
10             sub random_bytes {
11 16     16 1 41 my ($self, $count) = @_;
12 16         157 return Crypt::SysRandom::random_bytes($count);
13             }
14              
15             sub crypt_subtypes;
16              
17             sub accepts_hash {
18 28     28 1 69 my ($self, $hash) = @_;
19 28 50       103 return !!0 if not defined $hash;
20 28   66     134 $self->{accepts_hash} //= do {
21 20 50       86 my $string = join '|', $self->crypt_subtypes or return;
22 20         519 qr/ \A \$ (?: $string ) [\$,] /x;
23             };
24 28         382 return scalar $hash =~ $self->{accepts_hash};
25             }
26              
27             sub recode_hash {
28 0     0 1   my ($self, $hash, @args) = @_;
29 0           return $hash;
30             }
31              
32             1;
33              
34             #ABSTRACT: Base class for Crypt::Passphrase encoders
35              
36             __END__