File Coverage

blib/lib/Text/Password/Pronounceable/Harden.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             package Text::Password::Pronounceable::Harden;
2              
3 3     3   78601 use strict;
  3         7  
  3         117  
4 3     3   132 use warnings;
  3         78  
  3         101  
5 3     3   4152 use Moose;
  0            
  0            
6             use Text::Pipe;
7             use Text::Pipe::Stackable;
8             use Text::Password::Pronounceable;
9              
10             has pipe => (
11             is => 'ro',
12             builder => '_create_pipe',
13             lazy => 1,
14             isa => 'Text::Pipe::Stackable',
15             handles => [qw( pop push shift unshift count clear splice )]
16             );
17              
18             has generator => (
19             is => 'rw',
20             isa => 'Text::Password::Pronounceable',
21             lazy => 1,
22             builder => '_create_generator'
23             );
24              
25             has min => ( is => 'rw', isa => 'Int', default => 8 );
26             has max => ( is => 'rw', isa => 'Int', default => 8 );
27              
28             __PACKAGE__->meta->make_immutable;
29              
30             our $VERSION = '0.01';
31              
32             sub _create_pipe {
33             my ($self) = @_;
34             return Text::Pipe::Stackable->new();
35             }
36              
37             sub _create_generator {
38             my ($self) = @_;
39             return Text::Password::Pronounceable->new( $self->min, $self->max );
40             }
41              
42             sub add_filter {
43             my ( $self, $name, @args ) = @_;
44             my $pipe = Text::Pipe->new( $name, @args );
45             $self->pipe->push($pipe);
46             }
47              
48             sub generate {
49             my ($self) = @_;
50             my $password = $self->generator->generate( $self->min, $self->max );
51             return $self->pipe->filter($password);
52             }
53              
54             1;
55              
56             __END__
57              
58             =head1 NAME
59              
60             Text::Password::Pronounceable::Harden - harden your pronounceable passwords
61              
62             =head1 SYNOPSIS
63              
64             use Text::Password::Pronounceable::Harden;
65             my $pwgen = Text::Password::Pronounceable::Harden->new(min => 8, max => 12);
66             $pwgen->add_filter('RandomCase', probability => 2 );
67             $pwgen->generate();
68              
69             =head1 DESCRIPTION
70              
71             Althouh less secure than random passwords, most people have less
72             problems to remember chunks of pronounceable characters rather than
73             individual characters themselves. L<Text::Password::Pronounceable>
74             produces those, but it has the one disadvantage that it only uses
75             lower case characters. This module tries to solve this shortcoming
76             by providing a generic text filter to generate passwords that are
77             at the same time easy to remember and harder to crack.
78              
79             It's intended to be used with filters like L<Text::Pipe::RandomCase>,
80             but you can actually use any of Text::Pipes filters if you want to.
81              
82             =head1 CONSTRUCTION
83              
84             The following paramters can be passed to I<new()>, but none of these
85             are actually required:
86              
87             =over 4
88              
89             =item min
90              
91             The minimum numbers of characters a password should have. Defaults to 8.
92              
93             =item max
94              
95             The maximum numbers of characters a password should have. Defaults to 12.
96              
97             =item pipe
98              
99             A already initilized L<Text::Pipe::Stackable> object.
100              
101             =item generator
102              
103             A already initilized L<Text::Password::Pronounceable> object.
104              
105             =back
106              
107             =head1 METHODS
108              
109             =head2 generate($min, $max)
110              
111             Generates a new password with L<Text::Password::Pronounceable> and
112             filter it through every pipe added via I<add_filter> of the native
113             pipe methods.
114              
115             =head2 add_filter($name, @arguments)
116              
117             Add the pipe segment I<$name> to your stackable pipe and initialize it with I<@arguments>. The construct is syntactically identical to the following:
118              
119             my $pipe = Text::Pipe->new($name, @arguments);
120             $stacked_pipe->push($pipe);
121              
122             =head2 pop(), push(), shift(), unshift(), count(), clear() and splice()
123              
124             These methods are delegated to the underlying L<Text::Pipe::Stackable>
125             pipe attribute. Please note, that unlike I<add_filter()> you will
126             have to construct the pipe segments by hand with these methods.
127              
128             =head1 VERSION
129              
130             0.01
131              
132             =head1 AUTHOR
133              
134             Mario Domgoergen <mdom@cpan.org>
135              
136             =head1 BUGS
137              
138             Please report any bugs or feature requests to C<bug-text-password-pronounceable-harden
139             at rt.cpan.org>, or through the web interface at
140             L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Text-Passwort-Pronounceable-Harden>. I
141             will be notified, and then you'll automatically be notified of
142             progress on your bug as I make changes.
143              
144             =head1 SUPPORT
145              
146             You can find documentation for this module with the perldoc command.
147              
148             perldoc Text::Password::Pronounceable::Harden
149              
150             You can also look for information at:
151              
152             =over 4
153              
154             =item * RT: CPAN's request tracker
155              
156             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Text-Password-Pronounceable-Harden>
157              
158             =item * AnnoCPAN: Annotated CPAN documentation
159              
160             L<http://annocpan.org/dist/Text-Password-Pronounceable-Harden>
161              
162             =item * CPAN Ratings
163              
164             L<http://cpanratings.perl.org/d/Text-Password-Pronounceable-Harden>
165              
166             =item * Search CPAN
167              
168             L<http://search.cpan.org/dist/Text-Password-Pronounceable-Harden>
169              
170             =back
171              
172              
173             =head1 LICENSE AND COPYRIGHT
174              
175             Copyright 2008-2009 Mario Domgoergen.
176              
177             This program is free software; you can redistribute it and/or modify
178             it under the terms the GNU General Public License as published by
179             the Free Software Foundation; either version 1, or (at your option)
180             any later version.
181