NAME

Crypt::PassGen - Generate a random password that looks like a real word

SYNOPSIS

use Crypt::PassGen qw/ passgen /;

@passwords = passgen( NWORDS => 10, NLETT => 8 );

DESCRIPTION

This module provides a single command for generating random password that is close enough to a real word that it is easy to remember. It does this by using the frequency of letter combinations in a language (the frequency table is generated during installation although multiple tables can be generated and used for different languages). The frequency table contains the probability that a word will start with a specific letter or 2 letter combination and then the frequency of 3 letter combinations.

This module should not be used for high security applications (such as user accounts) since it returns passwords that are not mixed case, have no punctuation and no letters. This word can be used as a basis for a more secure password.

The language of the password depends on the language used to construct the frequency table.

FUNCTIONS

The following functions are provided:

ingest

This function is used to create a frequency table to be used later by passgen. This routine is run during the initial install of the module so that at least one frequency table is available.

This function reads a file and for each word that is found (ignoring any with non-alphabet characters) notes the starting letter, the second letter and each combination of 3 letters. Once the file is read the resultant arrays then contain the relative occurence of each letter combination. The frequency table will vary depending on the language of the input file.

ingest( DICT   => '/usr/dict/words',
        FILE   => 'wordfreq.dat',
        APPEND => 0)

The input hash can contain keys DICT, FILE and APPEND with the above defaults. All arguments are optional. If APPEND is true the frequency table from the input dictionary will be appended to an existing table (if it exists).

Returns 1 if successful and 0 otherwise. On error, the reason is stored in $Crypt::PassGen::ERRSTR.

A default frequency file is provided for passgen as part of the installation. This routine is only required to either extend or replace the default value.

passgen

Generate a password.

@words = passgen( %options );

Argument is a hash with the following keys:

FILE   The filename containing the frequency information. Must 
       have been written using C<ingest>.
NLETT  Number of letters to use for the generated password.
       Must be at least 5
NWORDS Number of passwords to generate

An array of passwords is returned. An empty list is returned if an error occurs (and $Crypt::PassGen::ERRSTR is set to the reason).

ERROR HANDLING

All routines in this module store errors in the ERRSTR variable. This variable can be accessed if the routines return an error state and contains the reason for the error.

@words = passgen( NLETT => 2 ) 
  or die "Error message: $Crypt::PassGen::ERRSTR";

AUTHORS

Tim Jenness <tjenness@cpan.org> Copyright (C) 2000-2012 T. Jenness. All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Based on the PASSGEN program written by Mike Bartman of SAR, Inc as part of the SPAN security toolkit.