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.021';
3 2     2   133650 use strict;
  2         5  
  2         90  
4 2     2   8 use warnings;
  2         4  
  2         130  
5              
6 2     2   10 use parent 'Crypt::Passphrase::Validator';
  2         3  
  2         15  
7              
8 2     2   1224 use Digest::SHA 'sha1';
  2         6718  
  2         517  
9              
10             sub new {
11 2     2 0 408 my $class = shift;
12 2         9 return bless {}, $class;
13             }
14              
15             sub accepts_hash {
16 4     4 1 15 my ($self, $hash) = @_;
17 4         17 return $hash =~ / ^ [a-f0-9]{40} $/xi;
18             }
19              
20             sub verify_password {
21 2     2 1 8 my ($self, $password, $hash) = @_;
22 2         31 return sha1($password) eq pack 'H40', $hash;
23             }
24              
25             1;
26              
27             # ABSTRACT: Validate against hexed SHA1 hashes with Crypt::Passphrase
28              
29             __END__