line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
10
|
|
|
10
|
|
963
|
use 5.008; |
|
10
|
|
|
|
|
35
|
|
|
10
|
|
|
|
|
396
|
|
2
|
10
|
|
|
10
|
|
63
|
use strict; |
|
10
|
|
|
|
|
20
|
|
|
10
|
|
|
|
|
321
|
|
3
|
10
|
|
|
10
|
|
291
|
use warnings; |
|
10
|
|
|
|
|
18
|
|
|
10
|
|
|
|
|
520
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Hook::Modular::Crypt; |
6
|
|
|
|
|
|
|
BEGIN { |
7
|
10
|
|
|
10
|
|
285
|
$Hook::Modular::Crypt::VERSION = '1.101050'; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
# ABSTRACT: Crypt mechanism for passwords in workflows |
10
|
|
|
|
|
|
|
use Module::Pluggable |
11
|
10
|
|
|
|
|
88
|
search_path => [qw/Hook::Modular::Crypt/], |
12
|
10
|
|
|
10
|
|
9600
|
require => 1; |
|
10
|
|
|
|
|
126393
|
|
13
|
|
|
|
|
|
|
my %handlers = map { $_->id => $_ } __PACKAGE__->plugins; |
14
|
|
|
|
|
|
|
my $re = "^(" . join("|", map $_->id, __PACKAGE__->plugins) . ")::"; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub decrypt { |
17
|
4
|
|
|
4
|
1
|
7738
|
shift; # we don't need the class |
18
|
4
|
|
|
|
|
10
|
my ($ciphertext, @args) = @_; |
19
|
4
|
100
|
|
|
|
56
|
if ($ciphertext =~ s!$re!!) { |
20
|
1
|
|
|
|
|
5
|
my $handler = $handlers{$1}; |
21
|
1
|
|
|
|
|
5
|
my @param = split /::/, $ciphertext; |
22
|
1
|
|
|
|
|
10
|
return $handler->decrypt(@param, @args); |
23
|
|
|
|
|
|
|
} |
24
|
3
|
|
|
|
|
13
|
return $ciphertext; # just plain text |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub encrypt { |
28
|
3
|
|
|
3
|
1
|
6
|
shift; # we don't need the class |
29
|
3
|
|
|
|
|
8
|
my ($plaintext, $driver, @param) = @_; |
30
|
3
|
50
|
|
|
|
14
|
my $handler = $handlers{$driver} |
31
|
|
|
|
|
|
|
or Hook::Modular::Crypt->context->error("No crypt handler for $driver"); |
32
|
3
|
|
|
|
|
25
|
join '::', $driver, $handler->encrypt($plaintext, @param); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
__END__ |