| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# |
|
2
|
|
|
|
|
|
|
# $Id$ |
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# string::password Brik |
|
5
|
|
|
|
|
|
|
# |
|
6
|
|
|
|
|
|
|
package Metabrik::String::Password; |
|
7
|
1
|
|
|
1
|
|
773
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
28
|
|
|
8
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
66
|
|
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
6
|
use base qw(Metabrik); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
497
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub brik_properties { |
|
13
|
|
|
|
|
|
|
return { |
|
14
|
0
|
|
|
0
|
1
|
|
revision => '$Revision$', |
|
15
|
|
|
|
|
|
|
tags => [ qw(unstable random) ], |
|
16
|
|
|
|
|
|
|
author => 'GomoR ', |
|
17
|
|
|
|
|
|
|
license => 'http://opensource.org/licenses/BSD-3-Clause', |
|
18
|
|
|
|
|
|
|
attributes => { |
|
19
|
|
|
|
|
|
|
charset => [ qw($character_list) ], |
|
20
|
|
|
|
|
|
|
length => [ qw(integer) ], |
|
21
|
|
|
|
|
|
|
count => [ qw(integer) ], |
|
22
|
|
|
|
|
|
|
}, |
|
23
|
|
|
|
|
|
|
attributes_default => { |
|
24
|
|
|
|
|
|
|
charset => [ 'A'..'K', 'M'..'Z', 'a'..'k', 'm'..'z', 2..9, '_', '-', '#', '!' ], |
|
25
|
|
|
|
|
|
|
length => 10, |
|
26
|
|
|
|
|
|
|
count => 5, |
|
27
|
|
|
|
|
|
|
}, |
|
28
|
|
|
|
|
|
|
commands => { |
|
29
|
|
|
|
|
|
|
generate => [ qw(length|OPTIONAL count|OPTIONAL) ], |
|
30
|
|
|
|
|
|
|
prompt => [ qw(string|OPTIONAL) ], |
|
31
|
|
|
|
|
|
|
}, |
|
32
|
|
|
|
|
|
|
require_modules => { |
|
33
|
|
|
|
|
|
|
'String::Random' => [ ], |
|
34
|
|
|
|
|
|
|
'Term::ReadPassword' => [ ], |
|
35
|
|
|
|
|
|
|
}, |
|
36
|
|
|
|
|
|
|
}; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub generate { |
|
40
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
41
|
0
|
|
|
|
|
|
my ($length, $count) = @_; |
|
42
|
|
|
|
|
|
|
|
|
43
|
0
|
|
0
|
|
|
|
$length ||= $self->length; |
|
44
|
0
|
|
0
|
|
|
|
$count ||= $self->count; |
|
45
|
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my $charset = $self->charset; |
|
47
|
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
my $rand = String::Random->new; |
|
49
|
0
|
|
|
|
|
|
$rand->{A} = $charset; |
|
50
|
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
my @passwords = (); |
|
52
|
0
|
|
|
|
|
|
for (1..$count) { |
|
53
|
0
|
|
|
|
|
|
push @passwords, $rand->randpattern("A"x$length); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
return \@passwords; |
|
57
|
|
|
|
|
|
|
} |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub prompt { |
|
60
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
61
|
0
|
|
|
|
|
|
my ($string) = @_; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
0
|
|
|
|
$string ||= 'Password: '; |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
my $password; |
|
66
|
0
|
|
|
|
|
|
while (1) { |
|
67
|
0
|
|
|
|
|
|
my $this = Term::ReadPassword::read_password($string); |
|
68
|
0
|
0
|
|
|
|
|
if (defined($this)) { |
|
69
|
0
|
|
|
|
|
|
$password = $this; |
|
70
|
0
|
|
|
|
|
|
last; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
} |
|
73
|
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
return $password; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
1; |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
__END__ |