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 πŸ”₯


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