File Coverage

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


line stmt bran cond sub pod time code
1             package CGI::Application::Plugin::Authentication::Driver::Filter::crypt;
2             $CGI::Application::Plugin::Authentication::Driver::Filter::crypt::VERSION = '0.21';
3 3     3   48728 use strict;
  3         5  
  3         91  
4 3     3   13 use warnings;
  3         37  
  3         557  
5              
6             sub check {
7 2     2 1 5 my $class = shift;
8 2         3 my $param = shift;
9 2         3 my $plain = shift;
10 2         3 my $filtered = shift;
11              
12 2 100       7 return ( $class->filter( $param, $plain, $filtered ) eq $filtered ) ? 1 : 0;
13             }
14              
15             sub filter {
16 20     20 1 184 my ($class, undef, $plain, $salt) = @_;
17 20 100       46 if (!$salt) {
18 13         237 my @alphabet = ( '.', '/', 0 .. 9, 'A' .. 'Z', 'a' .. 'z' );
19 13         88 $salt = join '', @alphabet[ rand 64, rand 64 ];
20             }
21 20         2085 return crypt( $plain, $salt );
22             }
23              
24             1;
25             __END__