File Coverage

blib/lib/Crypt/Passphrase/SHA1/Base64.pm
Criterion Covered Total %
statement 22 22 100.0
branch n/a
condition n/a
subroutine 8 8 100.0
pod 2 3 66.6
total 32 33 96.9


line stmt bran cond sub pod time code
1             package Crypt::Passphrase::SHA1::Base64;
2             $Crypt::Passphrase::SHA1::Base64::VERSION = '0.023';
3 2     2   236307 use strict;
  2         4  
  2         103  
4 2     2   12 use warnings;
  2         48  
  2         172  
5              
6 2     2   34 use parent 'Crypt::Passphrase::Validator';
  2         5  
  2         16  
7              
8 2     2   868 use Digest::SHA 'sha1';
  2         4387  
  2         206  
9 2     2   647 use MIME::Base64 'decode_base64';
  2         886  
  2         625  
10              
11             sub new {
12 2     2 0 435 my $class = shift;
13 2         11 return bless {}, $class;
14             }
15              
16             sub accepts_hash {
17 2     2 1 8 my ($self, $hash) = @_;
18 2         14 return $hash =~ m{ ^ [A-Za-z0-9+/]{27} =? $ }x;
19             }
20              
21             sub verify_password {
22 2     2 1 7 my ($self, $password, $hash) = @_;
23 2         14 my $new_hash = sha1($password);
24 2         15 return $self->secure_compare($new_hash, decode_base64($hash));
25             }
26              
27             1;
28              
29             # ABSTRACT: Validate against base64ed SHA1 hashes with Crypt::Passphrase
30              
31             __END__