++ed by:

1 non-PAUSE user(s).

Marc S. Brooks

NAME

String::Urandom - An alternative to using /dev/random

SYNOPSIS

  use String::Urandom;

  my $obj = String::Urandom->new(
      LENGTH => 55,
      CHARS  => [ qw/ a b c 1 2 3 / ]
    );

  print $obj->rand_string, "\n";

DESCRIPTION

Using output from /dev/urandom. Simply convert bytes into 8-bit characters.

PREREQUISITES

  Params::Validate

INSTALLATION

From source:

  $ tar xfz String-Urandom-0.X.X.tar.gz
  $ perl MakeFile.PL PREFIX=~/path/to/custom/dir LIB=~/path/to/custom/lib
  $ make
  $ make test
  $ make install

Perl one liner using CPAN.pm:

  $ perl -MCPAN -e 'install String::Urandom'

Use of CPAN.pm in interactive mode:

  $ perl -MCPAN -e shell
  cpan> install String::Urandom
  cpan> quit

Just like the manual installation of Perl modules, the user may need root access during this process to insure write permission is allowed within the installation directory.

OBJECT METHODS

new

Create a new session object. Configuration items may be passed as a parameter.

  my $obj = new String::Urandom;

    or

  my %params = (
      LENGTH => 55,
      CHARS  => [ qw/ a b c 1 2 3 / ]
    );

  my $obj = String::Urandom->new(\%params);

str_length

This method will Set/Get the string character length.

The default value is: 32

  $obj->str_length(55);

str_chars

This method will Set/Get characters used for generating a string.

The default value is: a-z A-Z 0-9

  $obj->str_chars('a b c 1 2 3');

rand_string

This method generates a new random string.

  $obj->rand_string;

PARAMETERS

LENGTH

Defines the length of the string in characters.

The default value is: 32

CHARS

Defines the characters used for generating the string.

The default value is: a-z A-Z 0-9

REQUIREMENTS

Any flavour of UNIX that supports /dev/urandom

SECURITY

In general, the longer the string length and total characters defined, the more secure the output result will be.

NOTES

The /dev/urandom is an ("unlocked" random source) which reuses the internal pool to produce more pseudo-random bits. Since this is the case, the read may contain less entropy than its counterpart /dev/random. Knowing this, this module was intended to be used as a pseudorandom string generator for less secure applications where response timing may be an issue.

SEE ALSO

urandom(4)

AUTHOR

Marc S. Brooks <mbrooks@cpan.org> http://mbrooks.info

COPYRIGHT

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See http://www.perl.com/perl/misc/Artistic.html

DISCLAIMER OF WARRANTY

BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR, OR CORRECTION.

IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.