line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
3
|
|
|
3
|
|
85046
|
use 5.008001; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
123
|
|
2
|
3
|
|
|
3
|
|
17
|
use strict; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
107
|
|
3
|
3
|
|
|
3
|
|
17
|
use warnings; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
216
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Crypt::Diceware; |
6
|
|
|
|
|
|
|
# ABSTRACT: Random passphrase generator loosely based on the Diceware algorithm |
7
|
|
|
|
|
|
|
our $VERSION = '0.005'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
3
|
|
|
3
|
|
2743
|
use Class::Load qw/load_class/; |
|
3
|
|
|
|
|
116032
|
|
|
3
|
|
|
|
|
171
|
|
10
|
3
|
|
|
3
|
|
4390
|
use Crypt::Rijndael; |
|
3
|
|
|
|
|
2404
|
|
|
3
|
|
|
|
|
86
|
|
11
|
3
|
|
|
3
|
|
3073
|
use Crypt::URandom; |
|
3
|
|
|
|
|
21462
|
|
|
3
|
|
|
|
|
193
|
|
12
|
3
|
|
|
3
|
|
2489
|
use Data::Entropy qw/with_entropy_source/; |
|
3
|
|
|
|
|
12115
|
|
|
3
|
|
|
|
|
182
|
|
13
|
3
|
|
|
3
|
|
2836
|
use Data::Entropy::Algorithms qw/pick_r/; |
|
3
|
|
|
|
|
39472
|
|
|
3
|
|
|
|
|
242
|
|
14
|
3
|
|
|
3
|
|
2857
|
use Data::Entropy::RawSource::CryptCounter; |
|
3
|
|
|
|
|
8225
|
|
|
3
|
|
|
|
|
109
|
|
15
|
3
|
|
|
3
|
|
3679
|
use Data::Entropy::Source; |
|
3
|
|
|
|
|
8739
|
|
|
3
|
|
|
|
|
163
|
|
16
|
|
|
|
|
|
|
|
17
|
3
|
|
|
|
|
34
|
use Sub::Exporter -setup => { |
18
|
|
|
|
|
|
|
exports => [ words => \'_build_words' ], |
19
|
|
|
|
|
|
|
groups => { default => [qw/words/] }, |
20
|
3
|
|
|
3
|
|
2795
|
}; |
|
3
|
|
|
|
|
11330
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
my $ENTROPY = Data::Entropy::Source->new( |
23
|
|
|
|
|
|
|
Data::Entropy::RawSource::CryptCounter->new( |
24
|
|
|
|
|
|
|
Crypt::Rijndael->new( Crypt::URandom::urandom(32) ) |
25
|
|
|
|
|
|
|
), |
26
|
|
|
|
|
|
|
"getc" |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub _build_words { |
30
|
6
|
|
|
6
|
|
1766
|
my ( $class, $name, $arg ) = @_; |
31
|
6
|
|
50
|
|
|
29
|
$arg ||= {}; |
32
|
6
|
|
|
|
|
8
|
my $list; |
33
|
6
|
|
66
|
|
|
86
|
my $entropy = $arg->{entropy} || $ENTROPY; |
34
|
6
|
100
|
|
|
|
22
|
if ( exists $arg->{file} ) { |
35
|
1
|
|
|
|
|
3
|
my @list = do { local (@ARGV) = $arg->{file}; <> }; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
643
|
|
36
|
1
|
|
|
|
|
56
|
chomp(@list); |
37
|
1
|
|
|
|
|
3
|
$list = \@list; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
else { |
40
|
5
|
|
100
|
|
|
60
|
my $word_class = $arg->{wordlist} || 'Common'; |
41
|
5
|
50
|
|
|
|
25
|
unless ( $word_class =~ /::/ ) { |
42
|
5
|
|
|
|
|
19
|
$word_class = "Crypt::Diceware::Wordlist::$word_class"; |
43
|
|
|
|
|
|
|
} |
44
|
5
|
|
|
|
|
26
|
load_class($word_class); |
45
|
5
|
|
|
|
|
458
|
$list = do { |
46
|
3
|
|
|
3
|
|
2010
|
no strict 'refs'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
633
|
|
47
|
5
|
|
|
|
|
9
|
\@{"${word_class}::Words"}; |
|
5
|
|
|
|
|
52
|
|
48
|
|
|
|
|
|
|
}; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
return sub { |
51
|
22
|
|
|
22
|
|
4041
|
my ($n) = @_; |
52
|
22
|
100
|
100
|
|
|
182
|
return unless $n && $n > 0; |
53
|
|
|
|
|
|
|
my @w = with_entropy_source( |
54
|
|
|
|
|
|
|
$entropy, |
55
|
|
|
|
|
|
|
sub { |
56
|
20
|
|
|
20
|
|
111
|
map { pick_r($list) } 1 .. int($n); |
|
78
|
|
|
|
|
6951
|
|
57
|
|
|
|
|
|
|
} |
58
|
20
|
|
|
|
|
138
|
); |
59
|
20
|
100
|
|
|
|
2770
|
return wantarray ? @w : join( ' ', @w ); |
60
|
6
|
|
|
|
|
76
|
}; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# vim: ts=2 sts=2 sw=2 et: |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__END__ |