25 Jan 2011 03:14:08 UTC
- Distribution: Math-Random-Secure
- Module version: 0.06
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (0)
- Testers (3902 / 0 / 2)
- KwaliteeBus factor: 0
- 94.53% Coverage
- License: artistic_2
- Activity24 month
- Download (13.47KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
Math::Random::Secure::RNG - The underlying PRNG, as an object.
use Math::Random::Secure::RNG; my $rng = Math::Random::Secure::RNG->new(); my $int = $rng->irand();
This represents a random number generator, as an object.
Generally, you shouldn't have to worry about this, and you should just use Math::Random::Secure. But if for some reason you want to modify how the random number generator works or you want an object-oriented interface to a random-number generator, you can use this.
Generates a random unsigned 32-bit integer.
Generates a random floating-point number greater than or equal to 0 and less than 1.
These are all options that can be passed to
new()or called as methods on an existing object.
The underlying random number generator. Defaults to an instance of Math::Random::ISAAC.
The random data used to seed "rng", as a string of bytes. This should be large enough to properly seed "rng". This means minimally, it should be 8 bytes (64 bits) and more ideally, 32 bytes (256 bits) or 64 bytes (512 bits). For an idea of how large your seed should be, see http://burtleburtle.net/bob/crypto/magnitude.html#brute for information on how long it would take to brute-force seeds of each size.
seedshould not be an integer, but a string of bytes.
It is very important that the seed be large enough, and also that the seed be very random. There are serious attacks possible against random number generators that are seeded with non-random data or with insufficient random data.
By default, we use a 512-bit (64 byte) seed. If Moore's Law continues to hold true, it will be approximately 1000 years before computers can brute-force a 512-bit (64 byte) seed at any reasonable speed (and physics suggests that computers will never actually become that fast, although there could always be improvements or new methods of computing we can't now imagine, possibly making Moore's Law continue to hold true forever).
See "seed" for more info about what is a reasonable seed size.
Module Install Instructions
To install Math::Random::Secure, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install Math::Random::Secure
For more information on module installation, please visit the detailed CPAN module installation guide.