File Coverage

blib/lib/Crypt/Passphrase/SHA1/Hex.pm
Criterion Covered Total %
statement 18 18 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 2 3 66.6
total 27 28 96.4


line stmt bran cond sub pod time code
1             package Crypt::Passphrase::SHA1::Hex;
2             $Crypt::Passphrase::SHA1::Hex::VERSION = '0.023';
3 2     2   181108 use strict;
  2         5  
  2         89  
4 2     2   12 use warnings;
  2         4  
  2         158  
5              
6 2     2   14 use parent 'Crypt::Passphrase::Validator';
  2         4  
  2         17  
7              
8 2     2   1558 use Digest::SHA 'sha1';
  2         8358  
  2         652  
9              
10             sub new {
11 2     2 0 412 my $class = shift;
12 2         8 return bless {}, $class;
13             }
14              
15             sub accepts_hash {
16 4     4 1 11 my ($self, $hash) = @_;
17 4         18 return $hash =~ / ^ [a-f0-9]{40} $/xi;
18             }
19              
20             sub verify_password {
21 2     2 1 7 my ($self, $password, $hash) = @_;
22 2         31 return $self->secure_compare(sha1($password), pack 'H40', $hash);
23             }
24              
25             1;
26              
27             # ABSTRACT: Validate against hexed SHA1 hashes with Crypt::Passphrase
28              
29             __END__