line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CGI::Application::Plugin::Authentication::Driver::Filter::md5; |
2
|
|
|
|
|
|
|
$CGI::Application::Plugin::Authentication::Driver::Filter::md5::VERSION = '0.21'; |
3
|
3
|
|
|
3
|
|
2330
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
90
|
|
4
|
3
|
|
|
3
|
|
13
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
87
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
413
|
use UNIVERSAL::require; |
|
3
|
|
|
|
|
1171
|
|
|
3
|
|
|
|
|
24
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub check { |
9
|
12
|
|
|
12
|
1
|
17
|
my $class = shift; |
10
|
12
|
|
|
|
|
10
|
my $param = shift; |
11
|
12
|
|
|
|
|
12
|
my $plain = shift; |
12
|
12
|
|
|
|
|
11
|
my $filtered = shift; |
13
|
|
|
|
|
|
|
|
14
|
12
|
100
|
|
|
|
28
|
if ($param) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
15
|
6
|
100
|
|
|
|
11
|
return ( $class->filter( $param, $plain ) eq $filtered ) ? 1 : 0; |
16
|
|
|
|
|
|
|
} elsif ( length($filtered) == 16 ) { |
17
|
2
|
100
|
|
|
|
5
|
return ( $class->filter( 'binary', $plain ) eq $filtered ) ? 1 : 0; |
18
|
|
|
|
|
|
|
} elsif ( length($filtered) == 22 ) { |
19
|
2
|
100
|
|
|
|
4
|
return ( $class->filter( 'base64', $plain ) eq $filtered ) ? 1 : 0; |
20
|
|
|
|
|
|
|
} else { |
21
|
2
|
100
|
|
|
|
6
|
return ( $class->filter( undef, $plain ) eq $filtered ) ? 1 : 0; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub filter { |
26
|
18
|
|
|
18
|
1
|
322
|
my $class = shift; |
27
|
18
|
|
100
|
|
|
55
|
my $param = lc (shift || 'hex'); |
28
|
18
|
|
|
|
|
18
|
my $plain = shift; |
29
|
|
|
|
|
|
|
|
30
|
18
|
100
|
|
|
|
63
|
Digest::MD5->require || die "Digest::MD5 is required to check MD5 passwords"; |
31
|
17
|
100
|
|
|
|
441
|
if ( $param eq 'hex' ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
32
|
6
|
|
|
|
|
39
|
return Digest::MD5::md5_hex($plain); |
33
|
|
|
|
|
|
|
} elsif ( $param eq 'base64' ) { |
34
|
5
|
|
|
|
|
31
|
return Digest::MD5::md5_base64($plain); |
35
|
|
|
|
|
|
|
} elsif ( $param eq 'binary' ) { |
36
|
5
|
|
|
|
|
38
|
return Digest::MD5::md5($plain); |
37
|
|
|
|
|
|
|
} |
38
|
1
|
|
|
|
|
9
|
die "Unknown MD5 format $param"; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
__END__ |