Data::Passphrase::Phrasebook - dictionaries for passphrase strength checking
Object-oriented interface:
use Data::Passphrase::Phrasebook; my $phrasebook = Data::Passphrase::Phrasebook->new({ file => '/usr/local/etc/passphrase/phrasebook', }); my $too_common = $phrasebook->has('april showers bring may flowers'); use Data::Passphrase::Phrasebook::Bloom; $phrasebook = Data::Passphrase::Phrasebook::Bloom->new({ file => '/usr/local/etc/passphrase/phrasebook', }); $too_common = $phrasebook->has('april showers bring may flowers');
Procedural interface:
use Data::Passphrase::Phrasebook qw(build_phrasebook phrasebook_check); my $phrasebook = build_phrasebook; my $too_common = phrasebook_check 'april showers bring may flowers'; $phrasebook = build_phrasebook 'bloom'; $too_common = phrasebook_check 'april showers bring may flowers';
This module provides a simple interface for using phrase dictionaries with Data::Passphrase.
This module provides a constructor new, which takes a reference to a hash of initial attribute settings, and accessor methods of the form get_attribute() and set_attribute(). See "Attributes".
new
The OO interface can be accessed via subclasses. For example, you'd call Data::Passphrase::Phrasebook::Bloom->new() to construct a phrasebook that uses a Bloom filter instead of the default Perl hash. The inherited methods and attributes are documented here.
In addition to the constructor and accessor methods, the following special methods are available.
$self->add($phrase)
Add $phrase to the phrasebook.
$phrase
$self->init_filter()
Initialize the filter attribute. May be useful for subclassing.
$self->load()
Load or reload the phrasebook specified by the file attribute. Rules are only reloaded if the file has been modified since the last time it was loaded.
$value = $self->has($phrase)
Return TRUE if the phrasebook contains $phrase, FALSE if it doesn't.
$self->normalize($phrase)
Normalize the phrase in preparation for comparison. The default method converts the phrase to lowercase and removes anything but letters and spaces.
The following attributes can be accessed via methods of the form get_attribute() and set_attribute().
If TRUE, enable debugging to the Apache error log.
The filename of the phrasebook. Each line represents one phrase.
The filter mechanism that holds the phrasebook data and determines whether supplied phrases are members. The default filter is a Perl hash. See also Data::Passphrase::Phrasebook::Bloom.
Unlike the object-oriented interface, the procedural interface can create any type of phrasebook, specified as the argument to build_phrasebook(). Then, phrasebook_check() is used to determine if a phrase is contained in the phrasebook.
$phrasebook = build_phrasebook $type
Build a phrasebook of type $type. This subroutine will essentially construct a new object of type
$type
"Data::Passphrase::Phrasebook::" . ucfirst $type
and return the phrasebook itself for use with phrasebook_check().
$value = phrasebook_check $phrasebook, $phrase
Returns TRUE if $phrase is contained by $phrasebook, FALSE if it isn't.
$phrasebook
Andrew J. Korty <ajk@iu.edu>
Data::Passphrase(3), Data::Passphrase::Phrasebook::Bloom(3)
To install Data::Passphrase, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Passphrase
CPAN shell
perl -MCPAN -e shell install Data::Passphrase
For more information on module installation, please visit the detailed CPAN module installation guide.