Andrew J. Korty > Data-Passphrase-0.0.7 > Data::Passphrase::Graph

Download:
Data-Passphrase-0.0.7.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Data::Passphrase::Graph - directed graphs for passphrase strength checking

SYNOPSIS ^

Object-oriented interface:

 use Data::Passphrase::Qwerty;

 my $graph = Data::Passphrase::Qwerty->new();
 print $graph->has('qwerty');          # prints 1
 print $graph->has('ytrewq');          # prints 1
 print $graph->has('qazxdr');          # prints 1
 print $graph->has('qwerfvgtrdxz');    # prints 1

 use Data::Passphrase::Roman;

 $graph = Data::Passphrase::Roman->new();
 print $graph->has('abcdef');          # prints 1
 print $graph->has('fedcba');          # prints 1
 print $graph->has('xyzabc');          # prints 1
 print $graph->has('cbazyx');          # prints 1

Procedural interface:

 use Data::Passphrase qw(build_graph graph_check);

 my $graph = build_graph 'qwerty';
 print graph_check $graph, 'qwerty';          # prints 1
 print graph_check $graph, 'ytrewq';          # prints 1
 print graph_check $graph, 'qazxdr';          # prints 1
 print graph_check $graph, 'qwerfvgtrdxz';    # prints 1

 $graph = build_graph 'roman';
 print graph_check $graph, 'abcdef';          # prints 1
 print graph_check $graph, 'fedcba';          # prints 1
 print graph_check $graph, 'xyzabc';          # prints 1
 print graph_check $graph, 'cbazyx';          # prints 1

DESCRIPTION ^

This module provides a simple interface for using directed graphs with Data::Passphrase to find trivial patterns in passphrases.

Graph Format

Graphs are represented by hashes. Each node on the graph is a key whose value is a hash of adjacent nodes. So a bidirectional graph of the alphabet would contain the element

 b => {a => 1, c => 1}

because each letter (b in this case) should be linked to both the previous letter (a) and the next letter (c). See "SYNOPSIS" and "EXAMPLES" for more examples.

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".

Normally, the OO interface is accessed via subclasses. For example, you'd call Data::Passphrase::Graph::Roman->new() to construct a graph of the alphabet. The inherited methods and attributes are documented here.

Methods

In addition to the constructor and accessor methods, the following special methods are available.

has()

 $value = $self->has($word)

Returns TRUE if $word is contained by the graph, FALSE if it isn't.

Attributes

The following attributes may be accessed via methods of the form get_attribute() and set_attribute().

debug

If TRUE, enable debugging to the Apache error log.

graph

The graph itself (see "Graph Format").

PROCEDURAL INTERFACE ^

Unlike the object-oriented interface, the procedural interface can create any type of graph, specified as the argument to build_graph(). Then, graph_check() is used to determine if a word is contained by the graph.

build_graph()

 $graph = build_graph $type

Build a graph of type $type. This subroutine will essentially construct a new object of the type

 "Data::Passphrase::Graph::" . ucfirst $type

and return the graph itself for use with graph_check().

graph_check()

 $value = graph_check $graph, $word

Returns TRUE if $word is contained by $graph, FALSE if it isn't.

EXAMPLES ^

The graph

   a -> b -> c
   ^         |
   `---------'

would be represented as

 %graph = (
     a => { b => 1 },
     b => { c => 1 },
     c => { a => 1 },
 );

Here's how to use it:

 $graph = Data::Passphrase::Graph->new({graph => \%graph});
 print $graph->has('abc');    # prints 1
 print $graph->has('cba');    # prints 0
 print $graph->has('cab');    # prints 1

AUTHOR ^

Andrew J. Korty <ajk@iu.edu>

SEE ALSO ^

Data::Passphrase(3)

syntax highlighting: