line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::Role::CryptedPassword; |
2
|
1
|
|
|
1
|
|
168705
|
use Moo::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.01_02'; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
346
|
use Crypt::CBC; |
|
1
|
|
|
|
|
11
|
|
|
1
|
|
|
|
|
40
|
|
7
|
1
|
|
|
1
|
|
19
|
use constant CIPHER => 'Rijndael'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
63
|
|
8
|
1
|
|
|
1
|
|
7
|
use constant CIPHER_KEY => 'BlahBlahBlahBlah'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
159
|
|
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
|
|
8
|
use autodie; |
|
1
|
|
|
|
|
2
|
|
|
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__ |