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.021';
3 2     2   243995 use strict;
  2         5  
  2         157  
4 2     2   16 use warnings;
  2         29  
  2         140  
5              
6 2     2   14 use parent 'Crypt::Passphrase::Validator';
  2         9  
  2         14  
7              
8 2     2   852 use Digest::SHA 'sha1';
  2         4968  
  2         222  
9 2     2   662 use MIME::Base64 'decode_base64';
  2         977  
  2         570  
10              
11             sub new {
12 2     2 0 395 my $class = shift;
13 2         10 return bless {}, $class;
14             }
15              
16             sub accepts_hash {
17 2     2 1 8 my ($self, $hash) = @_;
18 2         34 return $hash =~ m{ ^ [A-Za-z0-9+/]{27} =? $ }x;
19             }
20              
21             sub verify_password {
22 2     2 1 6 my ($self, $password, $hash) = @_;
23 2         15 my $new_hash = sha1($password);
24 2         17 return $new_hash eq decode_base64($hash);
25             }
26              
27             1;
28              
29             # ABSTRACT: Validate against base64ed SHA1 hashes with Crypt::Passphrase
30              
31             __END__