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.021';
3 2     2   188394 use strict;
  2         5  
  2         84  
4 2     2   11 use warnings;
  2         4  
  2         127  
5              
6 2     2   10 use parent 'Crypt::Passphrase::Validator';
  2         3  
  2         16  
7              
8 2     2   135 use Digest::MD5 'md5';
  2         4  
  2         154  
9 2     2   1043 use MIME::Base64 'decode_base64';
  2         1607  
  2         510  
10              
11             sub new {
12 2     2 0 417 my $class = shift;
13 2         9 return bless {}, $class;
14             }
15              
16             sub accepts_hash {
17 3     3 1 10 my ($self, $hash) = @_;
18 3         24 return $hash =~ m{ ^ [A-Za-z0-9+/]{22} (?:==)? $ }x;
19             }
20              
21             sub verify_password {
22 2     2 1 6 my ($self, $password, $hash) = @_;
23 2         10 my $new_hash = md5($password);
24 2         17 return $new_hash eq decode_base64($hash);
25             }
26              
27             1;
28              
29             # ABSTRACT: Validate against base64ed MD5 hashes with Crypt::Passphrase
30              
31             __END__