Math::...re::RNG(3pm)

πŸ“¦
version 0.080001 Β· 5 versions
, in debian bookworm, debian trixie, ubuntu jammy, ubuntu noble, ubuntu resolute, ubuntu stonking

✨ Math::...re::RNG πŸ’–

okay so bestie, this is the User Contributed Perl Documentation for Math::Random::Secure::RNG, and it is literally the little engine underneath the whole random-number situation πŸŽ€


🌸 NAME 🌸

Math::Random::Secure::RNG β€” the underlying PRNG, as an object. yes. an object. it's giving very OOP of it πŸ’…


⭐ VERSION ⭐

version 0.080001 β€” that's the vibe check, and it passed 🫢


🧚 SYNOPSIS 🧚

use Math::Random::Secure::RNG;
my $rng = Math::Random::Secure::RNG->new();
my $int = $rng->irand();

that's it. that's the whole thing. iconic behavior honestly 😭✨


πŸ’œ DESCRIPTION πŸ’œ

So this thing represents a random number generator, as an object. like, the RNG itself is now a lil guy you can hold πŸ₯Ί

ngl, generally you should not have to worry about this at all β€” you should just use Math::Random::Secure and go live your life. periodt. But if for some reason you wanna modify how the random number generator works, or you just really want an object-oriented interface to a random-number generator?? then bestie, this is your moment. main character energy, go off πŸ‘‘


πŸ”₯ METHODS πŸ”₯

irand 🎲

Generates a random unsigned 32-bit integer. big numbers, no negativity allowed πŸ’…

rand πŸ¦‹

Generates a random floating-point number that is greater than or equal to 0 and less than 1. so like 0 <= x < 1, no cap.


πŸ‘‘ ATTRIBUTES πŸ‘‘

These are all options that can be passed to new() or called as methods on an existing object. so you can set 'em at birth or later, whatever fits your schedule πŸŽ€

rng 🌈

The underlying random number generator. defaults to an instance of Math::Random::ISAAC. that's the plug fr fr.

seed 🌱

The random data used to seed rng, as a string of bytes. this should be large enough to properly seed rng. and "large enough" means, minimally, it should be 8 bytes (64 bits), and more ideally 32 bytes (256 bits) or 64 bytes (512 bits). if you want an idea of how large your seed should be, peep <http://burtleburtle.net/bob/crypto/magnitude.html#brute> for info on how long it would take to brute-force seeds of each size. nerd stuff, but important nerd stuff πŸ”

⚠️ note that seed should not be an integer β€” it should be a string of bytes. do not come in here with an integer, bestie, i'm begging 😭

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. like, this is the part where we do NOT play πŸ’€

By default, we use a 512-bit (64 byte) seed. and if Moore's Law <http://en.wikipedia.org/wiki/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.) so like. you're good. probably. 🧚✨

If you pass this to new(), seeder and seed_size will be ignored. they simply don't get a turn to speak πŸ™ˆ

seeder πŸ“

An instance of Crypt::Random::Source::Base that will be used to get the seed for rng. the lil seed supplier.

seed_size πŸ“

How much data (in bytes) should be read using seeder to seed rng. defaults to 64 bytes (which is 512 bits). a very generous default, honestly.

See seed for more info about what is a reasonable seed size. πŸ‘€


πŸ’– SEE ALSO πŸ’–

  • Math::Random::Secure

🌟 AUTHORS 🌟

  • Max Kanat-Alexander <mkanat@cpan.org>
  • Arthur Axel "fREW" Schmidt <math-random-secure@afoolishmanifesto.com>

legends, both of them 🫢


This software is Copyright (c) 2010 by BugzillaSource, Inc.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)

and that's a wrap bestie!! πŸŽ€ this lil doc came to you from perl v5.32.0, dated 2021-01-06, and honestly? she ate. go forth and generate random numbers responsibly, mwah πŸ’‹βœ¨