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.23';
3 3     3   50377 use strict;
  3         13  
  3         82  
4 3     3   14 use warnings;
  3         5  
  3         506  
5              
6             sub check {
7 2     2 1 5 my $class = shift;
8 2         3 my $param = shift;
9 2         4 my $plain = shift;
10 2         3 my $filtered = shift;
11              
12 2 100       4 return ( $class->filter( $param, $plain, $filtered ) eq $filtered ) ? 1 : 0;
13             }
14              
15             sub filter {
16 20     20 1 120 my ($class, undef, $plain, $salt) = @_;
17 20 100       59 if (!$salt) {
18 13         109 my @alphabet = ( '.', '/', 0 .. 9, 'A' .. 'Z', 'a' .. 'z' );
19 13         69 $salt = join '', @alphabet[ rand 64, rand 64 ];
20             }
21 20         1669 return crypt( $plain, $salt );
22             }
23              
24             1;
25             __END__