|  line  | 
 stmt  | 
 bran  | 
 cond  | 
 sub  | 
 pod  | 
 time  | 
 code  | 
| 
1
 | 
  
 
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 #  | 
| 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
3
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 package Data::SimplePassword;  | 
| 
4
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
5
 | 
10
 | 
 
 | 
 
 | 
  
10
  
 | 
 
 | 
76757
 | 
 use Moo;  | 
| 
 
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
108977
 | 
    | 
| 
 
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
47
 | 
    | 
| 
6
 | 
10
 | 
 
 | 
 
 | 
  
10
  
 | 
 
 | 
16829
 | 
 use MooX::ClassAttribute;  | 
| 
 
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
182114
 | 
    | 
| 
 
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
56
 | 
    | 
| 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
8
 | 
10
 | 
 
 | 
 
 | 
  
10
  
 | 
 
 | 
893
 | 
 use Carp;  | 
| 
 
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
18
 | 
    | 
| 
 
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
580
 | 
    | 
| 
9
 | 
10
 | 
 
 | 
 
 | 
  
10
  
 | 
 
 | 
3715
 | 
 use UNIVERSAL::require;  | 
| 
 
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9438
 | 
    | 
| 
 
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
75
 | 
    | 
| 
10
 | 
10
 | 
 
 | 
 
 | 
  
10
  
 | 
 
 | 
3748
 | 
 use Crypt::Random ();  | 
| 
 
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
186281
 | 
    | 
| 
 
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
5201
 | 
    | 
| 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
12
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 # ABSTRACT: Simple random password generator  | 
| 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 our $VERSION = '0.11';  | 
| 
15
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
16
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 class_has 'class' => (  | 
| 
17
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     is => 'rw',  | 
| 
18
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     default => sub {  | 
| 
19
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	Math::Random::MT->use  | 
| 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	    ? "Math::Random::MT"  | 
| 
21
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	    : Math::Random::MT::Perl->use  | 
| 
22
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 		? "Math::Random::MT::Perl"  | 
| 
23
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 		: "Data::SimplePassword::exception";  | 
| 
24
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     },  | 
| 
25
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 );  | 
| 
26
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
27
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has 'seed_num' => (  | 
| 
28
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     is => 'rw',  | 
| 
29
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     default => 1,    # now internal use only, up to 624  | 
| 
30
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 );  | 
| 
31
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
32
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has 'provider' => (  | 
| 
33
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     is => 'rw',  | 
| 
34
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     trigger => sub {  | 
| 
35
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	my $self = shift;  | 
| 
36
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	my ($provider) = @_;  | 
| 
37
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
38
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	$self->is_available_provider( $provider )  | 
| 
39
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	    or croak "RNG provider '$_[0]' is not available on this machine.";  | 
| 
40
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     },  | 
| 
41
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 );  | 
| 
42
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
43
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 has '_default_chars' => (  | 
| 
44
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     is => 'ro',  | 
| 
45
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     default => sub { [ 0..9, 'a'..'z', 'A'..'Z' ] },  | 
| 
46
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 );  | 
| 
47
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
48
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub chars {  | 
| 
49
 | 
48
 | 
 
 | 
 
 | 
  
48
  
 | 
  
1
  
 | 
5214
 | 
     my $self = shift;  | 
| 
50
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
51
 | 
48
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
95
 | 
     if( scalar @_ > 0 ){  | 
| 
52
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	croak "each chars must be a letter or an integer."  | 
| 
53
 | 
16
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
30
 | 
 	    if scalar grep { length( $_ ) != 1 } @_;  | 
| 
 
 | 
258
 | 
 
 | 
 
 | 
 
 | 
 
 | 
694
 | 
    | 
| 
54
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
55
 | 
13
 | 
 
 | 
 
 | 
 
 | 
 
 | 
79
 | 
 	$self->{_chars} = [ @_ ];  | 
| 
56
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
57
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
58
 | 
45
 | 
  
 50
  
 | 
 
 | 
 
 | 
 
 | 
180
 | 
     return wantarray ? @{ $self->{_chars} } : $self->{_chars};  | 
| 
 
 | 
  
0
  
 | 
 
 | 
 
 | 
 
 | 
 
 | 
0
 | 
    | 
| 
59
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
60
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
61
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub is_available_provider {  | 
| 
62
 | 
11
 | 
 
 | 
 
 | 
  
11
  
 | 
  
1
  
 | 
932
 | 
     my $self = shift;  | 
| 
63
 | 
11
 | 
 
 | 
 
 | 
 
 | 
 
 | 
29
 | 
     my ($provider) = @_;  | 
| 
64
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
65
 | 
11
 | 
  
100
  
 | 
  
 66
  
 | 
 
 | 
 
 | 
65
 | 
     if( defined $provider and $provider ne '' ){  | 
| 
66
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
84
 | 
 	my $pkg = sprintf "Crypt::Random::Provider::%s", $provider;  | 
| 
67
 | 
10
 | 
 
 | 
 
 | 
  
7
  
 | 
 
 | 
647
 | 
 	return eval "use $pkg; $pkg->available()";  | 
| 
 
 | 
7
 | 
 
 | 
 
 | 
  
2
  
 | 
 
 | 
2749
 | 
    | 
| 
 
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
23405
 | 
    | 
| 
 
 | 
7
 | 
 
 | 
 
 | 
 
 | 
 
 | 
67
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
10
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4
 | 
    | 
| 
 
 | 
2
 | 
 
 | 
 
 | 
 
 | 
 
 | 
6
 | 
    | 
| 
68
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
69
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
70
 | 
1
 | 
 
 | 
 
 | 
 
 | 
 
 | 
17
 | 
     return;  | 
| 
71
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
72
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
73
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 sub make_password {  | 
| 
74
 | 
21
 | 
 
 | 
 
 | 
  
21
  
 | 
  
1
  
 | 
248
 | 
     my $self = shift;  | 
| 
75
 | 
21
 | 
 
 | 
  
 50
  
 | 
 
 | 
 
 | 
45
 | 
     my $len = shift || 8;  | 
| 
76
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
77
 | 
21
 | 
  
100
  
 | 
 
 | 
 
 | 
 
 | 
240
 | 
     croak "length must be an integer."  | 
| 
78
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	unless $len =~ /^\d+$/o;  | 
| 
79
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
80
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my @chars = defined $self->chars && ref $self->chars eq 'ARRAY'  | 
| 
81
 | 
6
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9
 | 
 	? @{ $self->chars }  | 
| 
82
 | 
20
 | 
  
100
  
 | 
  
 66
  
 | 
 
 | 
 
 | 
48
 | 
 	: @{ $self->_default_chars };  | 
| 
 
 | 
14
 | 
 
 | 
 
 | 
 
 | 
 
 | 
148
 | 
    | 
| 
83
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
84
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     my $gen = $self->class->new(  | 
| 
85
 | 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
377
 | 
 	map { Crypt::Random::makerandom( Size => 32, Strength => 1, Provider => $self->provider ) } 1 .. $self->seed_num  | 
| 
 
 | 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
386
 | 
    | 
| 
86
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     );  | 
| 
87
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
88
 | 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
9989
 | 
     my $password;  | 
| 
89
 | 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
60
 | 
     while( $len-- ){  | 
| 
90
 | 
737
 | 
 
 | 
 
 | 
 
 | 
 
 | 
4386
 | 
 	$password .= $chars[ $gen->rand( scalar @chars ) ];  | 
| 
91
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
     }  | 
| 
92
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
93
 | 
20
 | 
 
 | 
 
 | 
 
 | 
 
 | 
242
 | 
     return $password;  | 
| 
94
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
95
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
96
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 {    package    # hide from PAUSE  | 
| 
97
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 	Data::SimplePassword::exception;  | 
| 
98
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
99
 | 
10
 | 
 
 | 
 
 | 
  
10
  
 | 
 
 | 
95
 | 
     use strict;  | 
| 
 
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
27
 | 
    | 
| 
 
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
242
 | 
    | 
| 
100
 | 
10
 | 
 
 | 
 
 | 
  
10
  
 | 
 
 | 
47
 | 
     use Carp;  | 
| 
 
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
23
 | 
    | 
| 
 
 | 
10
 | 
 
 | 
 
 | 
 
 | 
 
 | 
835
 | 
    | 
| 
101
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
102
 | 
0
 | 
 
 | 
 
 | 
  
0
  
 | 
 
 | 
0
 | 
     AUTOLOAD { croak "couldn't find any suitable MT classes." }  | 
| 
103
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 }  | 
| 
104
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
105
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 1;  | 
| 
106
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
    | 
| 
107
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 
 | 
 __END__  |