NAME
Math::BigInt::Random -- arbitrary sized random integers
DESCRIPTION
Random number generator
for
arbitrarily large integers.
Uses the Math::BigInt module to handle the generated
values
.
This module exports a single function called random_bigint, which returns
a single random Math::BigInt number of the specified range or size.
SYNOPSIS
use
Math::BigInt;
"random by max : "
, random_bigint(
max
=>
'10000000000000000000000000'
),
"\n"
,
"random by max and min : "
,
random_bigint(
min
=>
'7000000000000000000000000'
,
max
=>
'10000000000000000000000000'
),
"\n"
,
"random by length (base 10): "
,
random_bigint(
length
=> 20 ),
"\n"
,
"random by length (base 16) :"
,
random_bigint(
length_hex
=> 1,
length
=> 20)->as_hex,
"\n"
;
"random by length (base 2) :"
,
random_bigint(
length_bin
=> 1,
length
=> 319)->as_bin,
"\n"
;
"random from random.org"
:",
random_bigint(
max
=>
'3333333333333333000000000000000000000000'
,
min
=>
'3333333333333300000000000000000000000000'
,
use_internet
=> 1);
FUNCTION ARGUMENTS
This module exports a single function called random_bigint, which returns a single random Math::BigInt of arbitrary size.
Parameters to the function are given in paired hash style:
max
=>
$max
,
the maximum integer that can be returned. Either the
'max'
or the
'length'
parameter is mandatory. If both max and
length
are
given
, only the
'max'
parameter will be used. Note that the max must be >= 1.
min
=>
$min
,
which specifies the minimum integer that can be returned.
length
=>
$required_length
,
which specifies the number of digits (
with
most significant digit not 0).
Note that
if
max is specified,
length
will be ignored. However,
if
max is
not specified,
length
is a required argument.
length_hex
=> 1,
which specifies that,
if
length
is used, the
length
is that of the base 16
number, not the base 10 number which is the
default
for
the
length
.
length_bin
=> 1,
which specifies that,
if
length
is used, the
length
is that of the base 2
number, not the base 10 number which is the
default
for
the
length
. Note
that, due to discarding half the possible random numbers due to random
generation of a most significant place digit of 0, this method is about
half as efficient as
when
an exact maximum and minimum are
given
instead.
use_internet
=> 1,
which specifies that the random.org website will be used
for
random
number generation. Note this is NOT secure, since anyone monitoring
the connnection might be able to
read
the numbers that are received.
It is quite random, however.
Class Internal Methods and Functions
AUTHOR
William Herrera (wherrera@skylightview.com)
COPYRIGHT
Copyright (C) 2007 William Hererra. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.