line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
4
|
|
|
4
|
|
103644
|
use 5.008; |
|
4
|
|
|
|
|
17
|
|
|
4
|
|
|
|
|
158
|
|
2
|
4
|
|
|
4
|
|
23
|
use strict; |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
142
|
|
3
|
4
|
|
|
4
|
|
18
|
use warnings; |
|
4
|
|
|
|
|
15
|
|
|
4
|
|
|
|
|
152
|
|
4
|
4
|
|
|
4
|
|
4305
|
use utf8; |
|
4
|
|
|
|
|
40
|
|
|
4
|
|
|
|
|
21
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package Crypt::XkcdPassword; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
BEGIN { |
9
|
4
|
|
|
4
|
|
250
|
$Crypt::XkcdPassword::AUTHORITY = "cpan:TOBYINK"; |
10
|
4
|
|
|
|
|
86
|
$Crypt::XkcdPassword::VERSION = "0.009"; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
4
|
|
13904
|
use match::simple qw( match ); |
|
4
|
|
|
|
|
41596
|
|
|
4
|
|
|
|
|
50
|
|
14
|
4
|
|
|
4
|
|
940
|
use Carp qw( carp croak ); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
307
|
|
15
|
4
|
|
|
4
|
|
3870
|
use Module::Runtime qw( require_module ); |
|
4
|
|
|
|
|
8113
|
|
|
4
|
|
|
|
|
25
|
|
16
|
4
|
|
|
4
|
|
4118
|
use Types::Standard 1.000000 qw( CodeRef Str ConsumerOf ArrayRef ); |
|
4
|
|
|
|
|
301610
|
|
|
4
|
|
|
|
|
71
|
|
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
4
|
|
317576
|
use Moo 1.006000; |
|
4
|
|
|
|
|
64346
|
|
|
4
|
|
|
|
|
31
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
has rng => ( |
21
|
|
|
|
|
|
|
is => "rw", |
22
|
|
|
|
|
|
|
isa => CodeRef, |
23
|
|
|
|
|
|
|
default => sub { sub { int(rand($_[0])) } }, |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $wordrole = 'Crypt::XkcdPassword::Words'; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has words => ( |
29
|
|
|
|
|
|
|
is => "rw", |
30
|
|
|
|
|
|
|
isa => ConsumerOf->of($wordrole)->plus_coercions( |
31
|
|
|
|
|
|
|
Str, sub { require_module("$wordrole\::$_")->new }, |
32
|
|
|
|
|
|
|
ArrayRef, sub { my ($c, @a) = @$_; require_module("$wordrole\::$c")->new(@a) }, |
33
|
|
|
|
|
|
|
), |
34
|
|
|
|
|
|
|
coerce => 1, |
35
|
|
|
|
|
|
|
default => sub { "EN" }, |
36
|
|
|
|
|
|
|
handles => { _word_list => 'words' }, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
0
|
|
0
|
*chars = *provider = sub {}; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub make_password |
42
|
|
|
|
|
|
|
{ |
43
|
9
|
|
|
9
|
1
|
710
|
my $self = shift; |
44
|
9
|
|
|
|
|
21
|
my ($length, $filter) = @_; |
45
|
|
|
|
|
|
|
|
46
|
9
|
50
|
|
|
|
34
|
$self = $self->new unless ref $self; |
47
|
|
|
|
|
|
|
|
48
|
9
|
100
|
|
|
|
29
|
$length = 4 unless defined $length; |
49
|
9
|
100
|
|
|
|
2872
|
$length = 4 unless $length > 0; |
50
|
|
|
|
|
|
|
|
51
|
9
|
|
|
|
|
527
|
my $rng = $self->rng; |
52
|
9
|
|
|
|
|
4910
|
my $words = $self->_word_list; |
53
|
9
|
|
|
|
|
20
|
my $word_count = @$words; |
54
|
|
|
|
|
|
|
|
55
|
9
|
|
|
|
|
15
|
my @password; |
56
|
9
|
|
|
|
|
101
|
while (@password < $length) |
57
|
|
|
|
|
|
|
{ |
58
|
47
|
|
|
|
|
232
|
local $_ = my $maybe = $words->[ $rng->($word_count) ]; |
59
|
47
|
100
|
100
|
|
|
307
|
push @password, $maybe |
60
|
|
|
|
|
|
|
if (!defined $filter or match($maybe, $filter)); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
9
|
|
|
|
|
100
|
join q{ }, @password; |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__PACKAGE__ |
67
|
|
|
|
|
|
|
__END__ |