line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Crypt::XkcdPassword; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
101233
|
use 5.010001; |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
142
|
|
4
|
4
|
|
|
4
|
|
4179
|
use utf8; |
|
4
|
|
|
|
|
39
|
|
|
4
|
|
|
|
|
18
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
BEGIN { |
7
|
4
|
|
|
4
|
|
222
|
$Crypt::XkcdPassword::AUTHORITY = "cpan:TOBYINK"; |
8
|
4
|
|
|
|
|
91
|
$Crypt::XkcdPassword::VERSION = "0.005"; |
9
|
|
|
|
|
|
|
} |
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
3707
|
use match::simple qw( M ); |
|
4
|
|
|
|
|
35169
|
|
|
4
|
|
|
|
|
39
|
|
12
|
4
|
|
|
4
|
|
8585
|
use Carp qw( carp croak ); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
205
|
|
13
|
4
|
|
|
4
|
|
3522
|
use Module::Runtime qw( require_module ); |
|
4
|
|
|
|
|
6820
|
|
|
4
|
|
|
|
|
21
|
|
14
|
4
|
|
|
4
|
|
4082
|
use Types::Standard qw( CodeRef Str ); |
|
4
|
|
|
|
|
292320
|
|
|
4
|
|
|
|
|
68
|
|
15
|
|
|
|
|
|
|
|
16
|
4
|
|
|
4
|
|
7224
|
use Moo; |
|
4
|
|
|
|
|
58343
|
|
|
4
|
|
|
|
|
28
|
|
17
|
|
|
|
|
|
|
with qw(Role::Commons::Authority); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has rng => ( |
20
|
|
|
|
|
|
|
is => "rw", |
21
|
|
|
|
|
|
|
isa => CodeRef, |
22
|
|
|
|
|
|
|
default => sub { sub { int(rand($_[0])) } }, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has words => ( |
26
|
|
|
|
|
|
|
is => "rw", |
27
|
|
|
|
|
|
|
isa => Str, |
28
|
|
|
|
|
|
|
default => sub { "EN" }, |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
0
|
|
0
|
*chars = *provider = sub {}; |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub make_password |
34
|
|
|
|
|
|
|
{ |
35
|
9
|
|
|
9
|
1
|
2240
|
my ($self, $length, $filter) = @_; |
36
|
|
|
|
|
|
|
|
37
|
9
|
50
|
|
|
|
32
|
$self = $self->new unless ref $self; |
38
|
|
|
|
|
|
|
|
39
|
9
|
100
|
|
|
|
30
|
$length = 4 unless defined $length; |
40
|
9
|
100
|
|
|
|
28
|
$length = 4 unless $length > 0; |
41
|
|
|
|
|
|
|
|
42
|
9
|
|
|
|
|
175
|
my $rng = $self->rng; |
43
|
9
|
|
|
|
|
1808
|
my $words = $self->_word_list; |
44
|
9
|
|
|
|
|
31
|
my $word_count = @$words; |
45
|
|
|
|
|
|
|
|
46
|
9
|
|
|
|
|
17
|
my @password; |
47
|
9
|
|
|
|
|
39
|
while (@password < $length) |
48
|
|
|
|
|
|
|
{ |
49
|
47
|
|
|
|
|
843
|
local $_ = my $maybe = $words->[ $rng->($word_count) ]; |
50
|
47
|
100
|
100
|
|
|
337
|
push @password, $maybe |
51
|
|
|
|
|
|
|
if (!defined $filter or $maybe |M| $filter); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
9
|
|
|
|
|
183
|
return join q{ }, @password; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub _word_list |
58
|
|
|
|
|
|
|
{ |
59
|
9
|
|
|
9
|
|
18
|
my ($self) = @_; |
60
|
9
|
|
|
|
|
151
|
my $class = sprintf "Crypt::XkcdPassword::Words::%s", $self->words; |
61
|
|
|
|
|
|
|
|
62
|
9
|
50
|
|
|
|
1770
|
eval { require_module($class) } or do { |
|
9
|
|
|
|
|
39
|
|
63
|
0
|
|
|
|
|
0
|
carp "$class could not be loaded, switching to 'EN'"; |
64
|
0
|
0
|
|
|
|
0
|
croak "No point switching!" if $self->words eq "EN"; |
65
|
0
|
|
|
|
|
0
|
$self->words("EN"); |
66
|
0
|
|
|
|
|
0
|
return $self->_word_list; |
67
|
|
|
|
|
|
|
}; |
68
|
|
|
|
|
|
|
|
69
|
9
|
|
|
|
|
189
|
return $class->words; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__PACKAGE__ |
73
|
|
|
|
|
|
|
__END__ |