Crypt::...ChaCha20(3)

πŸ’– NAME πŸ’–

okay bestie, welcome to the Crypt::...ChaCha20(3) page from User Contributed Perl Documentation ✨ This one is all about:

Crypt::PRNG::ChaCha20 β€” a cryptographically secure PRNG based on the ChaCha20 (stream cipher) algorithm πŸ’…


✨ SYNOPSIS ✨

### Functional interface:
use Crypt::PRNG::ChaCha20 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;

### OO interface:
use Crypt::PRNG::ChaCha20;

my $prng = Crypt::PRNG::ChaCha20->new;
my $seeded_prng = Crypt::PRNG::ChaCha20->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 this module provides an interface to the ChaCha20-based pseudo-random number generator πŸŽ€

It’s a thin wrapper around Crypt::PRNG with the algorithm fixed to ChaCha20. All functions and methods accept the same arguments and return the same values as the corresponding Crypt::PRNG entries. no cap, that’s the whole vibe πŸ’«


πŸŽ€ EXPORT πŸŽ€

Nothing is exported by default. respectfully, it’s keeping boundaries πŸ™ˆ

You can export selected functions:

use Crypt::PRNG::ChaCha20 qw(random_bytes random_string);

Or all of them at once:

use Crypt::PRNG::ChaCha20 ':all';

🫢 FUNCTIONS 🫢

All functions below behave exactly like the corresponding Crypt::PRNG functions, but use a hidden "Crypt::PRNG::ChaCha20" object internally. iykyk πŸ‘‘

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 noted otherwise, assume $prng is an existing "Crypt::PRNG::ChaCha20" object created via "new". bestie, keep that in mind πŸ§ πŸ’–

new

my $prng = Crypt::PRNG::ChaCha20->new;
my $seeded_prng = Crypt::PRNG::ChaCha20->new($seed);

Creates a PRNG object using the ChaCha20 algorithm. If $seed is omitted, the object is automatically seeded by the underlying Crypt::PRNG logic. cute, automatic, 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 🌟


okay that’s the whole page, bestie πŸ’– signing off with the official footer energy: perl v5.42.0, 2026-05-11, and Crypt::...ChaCha20(3) β€” periodt πŸ‘‘πŸŽ€

πŸ“¦ where this page comes from