File Coverage

blib/lib/CGI/Application/Plugin/Authentication/Driver/Filter/crypt.pm
Criterion Covered Total %
statement 19 19 100.0
branch 4 4 100.0
condition n/a
subroutine 4 4 100.0
pod 2 2 100.0
total 29 29 100.0


line stmt bran cond sub pod time code
1             package CGI::Application::Plugin::Authentication::Driver::Filter::crypt;
2              
3 4     4   25433 use strict;
  4         9  
  4         206  
4 4     4   24 use warnings;
  4         8  
  4         5365  
5             our $VERSION = '0.20';
6              
7             sub check {
8 2     2 1 5 my $class = shift;
9 2         3 my $param = shift;
10 2         4 my $plain = shift;
11 2         3 my $filtered = shift;
12              
13 2 100       6 return ( $class->filter( $param, $plain, $filtered ) eq $filtered ) ? 1 : 0;
14             }
15              
16             sub filter {
17 25     25 1 58 my $class = shift;
18 25         1186 my $param = lc shift; # not used
19 25         48 my $plain = shift;
20 25         36 my $salt = shift;
21 25 100       68 if (!$salt) {
22 13         145 my @alphabet = ( '.', '/', 0 .. 9, 'A' .. 'Z', 'a' .. 'z' );
23 13         99 $salt = join '', @alphabet[ rand 64, rand 64 ];
24             }
25 25         5493 return crypt( $plain, $salt );
26             }
27              
28             1;
29             __END__