Crypt::...Fortuna(3)
π Crypt::PRNG::Fortuna(3) β the Crypt::...Fortuna manual, bestie edition π
okay so picture this: Perl's user-contributed docs, page Crypt::...Fortuna(3), but make it a group chat. that's it, that's the vibe. let's go π
β¨ NAME β¨
Crypt::PRNG::Fortuna β a cryptographically secure PRNG based on the Fortuna algorithm. yes bestie, cryptographically secure, we do not play about randomness here π
πΈ SYNOPSIS πΈ
two whole ways to do this, pick your fighter π«Ά
the functional interface, aka grab-the-functions-directly:
### Functional interface:
use Crypt::PRNG::Fortuna qw(random_bytes random_bytes_hex random_bytes_b64 random_bytes_b64u
random_string random_string_from rand irand);
my $octets = random_bytes(45);
my $hex_string = random_bytes_hex(45);
my $base64_string = random_bytes_b64(45);
my $base64url_string = random_bytes_b64u(45);
my $alphanumeric_string = random_string(30);
my $string = random_string_from('ACGT', 64);
my $floating_point_number_0_to_1 = rand;
my $floating_point_number_0_to_88 = rand(88);
my $unsigned_32bit_int = irand;
the OO interface, aka object-oriented main character energy:
### OO interface:
use Crypt::PRNG::Fortuna;
my $prng = Crypt::PRNG::Fortuna->new;
my $seeded_prng = Crypt::PRNG::Fortuna->new("some data used for seeding PRNG");
my $octets = $prng->bytes(45);
my $hex_string = $prng->bytes_hex(45);
my $base64_string = $prng->bytes_b64(45);
my $base64url_string = $prng->bytes_b64u(45);
my $alphanumeric_string = $prng->string(30);
my $string = $prng->string_from('ACGT', 64);
my $floating_point_number_0_to_1 = $prng->double;
my $floating_point_number_0_to_88 = $prng->double(88);
my $unsigned_32bit_int = $prng->int32;
π¦ DESCRIPTION π¦
so what is this actually? it provides an interface to the Fortuna-based pseudo-random number generator. slay. β¨
here's the tea though: this module is a thin wrapper around Crypt::PRNG with the algorithm fixed to Fortuna. that's the whole plot twist. every function and method takes the same arguments and hands back the same values as the corresponding Crypt::PRNG entries. literally no surprises, no cap π§
π EXPORT π
nothing is exported by default. nope, not a single one. you gotta ask nicely π
you can export selected functions, like the picky icon you are:
use Crypt::PRNG::Fortuna qw(random_bytes random_string);
or go full all-in, no notes:
use Crypt::PRNG::Fortuna ':all';
β FUNCTIONS β
every single function below behaves exactly like the corresponding Crypt::PRNG function β the only difference is it uses a hidden Crypt::PRNG::Fortuna object internally. sneaky. love that for us π
random_bytes
see "random_bytes" in Crypt::PRNG.
random_bytes_hex
see "random_bytes_hex" in Crypt::PRNG.
random_bytes_b64
see "random_bytes_b64" in Crypt::PRNG.
random_bytes_b64u
see "random_bytes_b64u" in Crypt::PRNG.
random_string
see "random_string" in Crypt::PRNG.
random_string_from
see "random_string_from" in Crypt::PRNG.
rand
see "rand" in Crypt::PRNG.
irand
see "irand" in Crypt::PRNG.
π METHODS π
unless it says otherwise, just assume $prng is an existing Crypt::PRNG::Fortuna object that you made via "new". k? k. π«Ά
new
my $prng = Crypt::PRNG::Fortuna->new;
my $seeded_prng = Crypt::PRNG::Fortuna->new($seed);
creates a PRNG object using the Fortuna algorithm. if $seed is omitted, the object gets automatically seeded by the underlying Crypt::PRNG logic β it handles itself, honestly iconic π
bytes
see "bytes" in Crypt::PRNG.
bytes_hex
see "bytes_hex" in Crypt::PRNG.
bytes_b64
see "bytes_b64" in Crypt::PRNG.
bytes_b64u
see "bytes_b64u" in Crypt::PRNG.
string
see "string" in Crypt::PRNG.
string_from
see "string_from" in Crypt::PRNG.
double
see "double" in Crypt::PRNG.
int32
see "int32" in Crypt::PRNG.
π₯ SEE ALSO π₯
Crypt::PRNG- <https://en.wikipedia.org/wiki/Fortuna_%28PRNG%29>
and that's the page! π this gem is from perl v5.42.0, dated 2026-05-11 β go forth and be cryptographically secure, bestie π¦β¨π
π¦ where this page comes from
- opensuse-leap 16.0: perl-CryptX 0.89.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-CryptX 0.89.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-CryptX 0.89.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- opensuse-leap 16.0: perl-CryptX 0.89.0-bp160.1.1 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms