NAME
Data::Passphrase::Phrasebook - dictionaries for passphrase strength checking
SYNOPSIS
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';
DESCRIPTION
This module provides a simple interface for using phrase dictionaries with Data::Passphrase.
OBJECT-ORIENTED INTERFACE
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".
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.
Methods
In addition to the constructor and accessor methods, the following special methods are available.
add()
$self->add($phrase)
Add $phrase
to the phrasebook.
init_filter()
$self->init_filter()
Initialize the filter attribute. May be useful for subclassing.
load()
$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.
has()
$value = $self->has($phrase)
Return TRUE if the phrasebook contains $phrase
, FALSE if it doesn't.
normalize()
$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.
Attributes
The following attributes can be accessed via methods of the form get_attribute() and set_attribute().
debug
If TRUE, enable debugging to the Apache error log.
file
The filename of the phrasebook. Each line represents one phrase.
filter
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.
PROCEDURAL INTERFACE
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.
build_phrasebook()
$phrasebook = build_phrasebook $type
Build a phrasebook of type $type
. This subroutine will essentially construct a new object of type
"Data::Passphrase::Phrasebook::" . ucfirst $type
and return the phrasebook itself for use with phrasebook_check().
phrasebook_check()
$value = phrasebook_check $phrasebook, $phrase
Returns TRUE if $phrase
is contained by $phrasebook
, FALSE if it isn't.
AUTHOR
Andrew J. Korty <ajk@iu.edu>
SEE ALSO
Data::Passphrase(3), Data::Passphrase::Phrasebook::Bloom(3)