line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MooX::Role::CryptedPassword; |
2
|
1
|
|
|
1
|
|
124952
|
use Moo::Role; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
279
|
use Crypt::CBC; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
7
|
1
|
|
|
1
|
|
20
|
use constant CIPHER => 'Rijndael'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
54
|
|
8
|
1
|
|
|
1
|
|
5
|
use constant CIPHER_KEY => 'BlahBlahBlahBlah'; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
122
|
|
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
|
|
13
|
use autodie; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
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__ |