File Coverage

blib/lib/Crypt/Passphrase/MD5/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::MD5::Base64;
2             $Crypt::Passphrase::MD5::Base64::VERSION = '0.023';
3 2     2   190483 use strict;
  2         7  
  2         89  
4 2     2   12 use warnings;
  2         4  
  2         160  
5              
6 2     2   15 use parent 'Crypt::Passphrase::Validator';
  2         24  
  2         17  
7              
8 2     2   139 use Digest::MD5 'md5';
  2         4  
  2         193  
9 2     2   1288 use MIME::Base64 'decode_base64';
  2         1976  
  2         614  
10              
11             sub new {
12 2     2 0 406 my $class = shift;
13 2         9 return bless {}, $class;
14             }
15              
16             sub accepts_hash {
17 3     3 1 9 my ($self, $hash) = @_;
18 3         23 return $hash =~ m{ ^ [A-Za-z0-9+/]{22} (?:==)? $ }x;
19             }
20              
21             sub verify_password {
22 2     2 1 7 my ($self, $password, $hash) = @_;
23 2         9 my $new_hash = md5($password);
24 2         16 return $self->secure_compare($new_hash, decode_base64($hash));
25             }
26              
27             1;
28              
29             # ABSTRACT: Validate against base64ed MD5 hashes with Crypt::Passphrase
30              
31             __END__