line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::Role::CryptedPassword; |
2
|
1
|
|
|
1
|
|
179030
|
use Moo::Role; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
6
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.01_03'; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
339
|
use Crypt::CBC; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
48
|
|
7
|
1
|
|
|
1
|
|
25
|
use constant CIPHER => 'Rijndael'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
67
|
|
8
|
1
|
|
|
1
|
|
6
|
use constant CIPHER_KEY => 'BlahBlahBlahBlah'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
153
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has password => ( |
11
|
|
|
|
|
|
|
is => 'ro', |
12
|
|
|
|
|
|
|
isa => sub { !ref $_[0] }, |
13
|
|
|
|
|
|
|
required => 1 |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
around BUILDARGS => sub { |
17
|
|
|
|
|
|
|
my $buildargs = shift; |
18
|
|
|
|
|
|
|
my $class = shift; |
19
|
|
|
|
|
|
|
my %args = @_; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
if (my $pwfile = delete($args{password_file})) { |
22
|
|
|
|
|
|
|
my $cipher_name = delete($args{cipher}) || CIPHER; |
23
|
|
|
|
|
|
|
my $cipher_key = delete($args{cipher_key}) || CIPHER_KEY; |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
1
|
|
16
|
use autodie; |
|
1
|
|
|
|
|
17
|
|
|
1
|
|
|
|
|
8
|
|
26
|
|
|
|
|
|
|
open my $fh, '<:raw', $pwfile; |
27
|
|
|
|
|
|
|
my $crypted_password = do {local $/; <$fh>}; |
28
|
|
|
|
|
|
|
close($fh); |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
my $cipher = Crypt::CBC->new( |
31
|
|
|
|
|
|
|
-cipher => $cipher_name, |
32
|
|
|
|
|
|
|
-key => $cipher_key, |
33
|
|
|
|
|
|
|
-pbkdf => 'pbkdf2', |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
$args{password} = $cipher->decrypt($crypted_password); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$class->$buildargs(%args); |
39
|
|
|
|
|
|
|
}; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |