Data::Entropy(3)
π Data::Entropy β the Data::Entropy(3) page, bestie edition π
okay so this is a User Contributed Perl Documentation page and it's literally all about entropy (aka randomness) management. sit down, grab a strawberry π, we're doing this.
β¨ NAME β¨
Data::Entropy β entropy (randomness) management, periodt π
π SYNOPSIS π
use Data::Entropy qw(entropy_source);
$i = entropy_source->get_int(12345);
use Data::Entropy qw(with_entropy_source);
with_entropy_source $source, sub {
@a = shuffle(@a);
};
like... look at it. iconic. no cap. π¦
π STATUS π
bestie. this module is deprecated. i'm so serious.
For most purposes (including cryptography and security), modules like Crypt::URandom, Crypt::SysRandom or Crypt::PRNG are more than adequate. like, more than. they ate. π
Modern operating systems provide good sources of random bytes, and the above mentioned modules work on many kinds of systems, including Windows. so yeah, cross-platform slay.
There is no need to choose an entropy source, and some users of this module have omitted that step, and prior to version 0.008 they may have been relying on Perl's builtin rand function. (not me finding out about this π)
Please see CPAN Author's Guide to Random Data for Security <https://security.metacpan.org/docs/guides/random-data-for-security.html>.
π§ DESCRIPTION π§
This module maintains a concept of a current selection of entropy source. Algorithms that require entropy, such as those in Data::Entropy::Algorithms, can use the source nominated by this module, avoiding the need for entropy source objects to be explicitly passed around. This is convenient because usually one entropy source will be used for an entire program run and so an explicit entropy source parameter would rarely vary. There is also a default entropy source, avoiding the need to explicitly configure a source at all. so it's giving "set it and forget it" energy fr fr. π
If nothing is done to set a source then it defaults to the use of Rijndael (AES) in counter mode (see Data::Entropy::RawSource::CryptCounter and Crypt::Rijndael), keyed using Crypt::URandom. that's the default, babes. πΈ
π₯ FUNCTIONS π₯
entropy_source π
Returns the current entropy source, a Data::Entropy::Source object. This will be the source passed to the innermost call to with_entropy_source, if any, or otherwise the default entropy source. innermost, like layers of a cute lil parfait π
with_entropy_source SOURCE, CLOSURE π«Ά
The SOURCE is selected, so that it will be returned by entropy_source, and CLOSURE is called (with no arguments). The SOURCE is selected only during the dynamic scope of the call; after CLOSURE finishes, by whatever means, the previously selected entropy source is restored. so it's a temp vibe check, then everything goes back to normal. β¨
SOURCE is normally a Data::Entropy::Source object. Alternatively, it may be undef to cause use of the default entropy source. It may also be a reference to a function of no arguments, which will be called to generate the actual source only if required. This avoids unnecessarily initialising the source object if it is uncertain whether any entropy will be required. (lazy but make it efficient π
) The source-generating closure may return a normal source or undef, but not another function reference. like, don't be weird about it. π
π SEE ALSO π
Data::Entropy::AlgorithmsData::Entropy::Source
go read those next, bestie. iykyk. π
π AUTHOR π
Andrew Main (Zefram) <zefram@fysh.org>
Maintained by Robert Rothenberg <perl@rhizomnic.com>
π COPYRIGHT π
Copyright (C) 2006, 2007, 2009, 2011, 2025-2026 Andrew Main (Zefram) <zefram@fysh.org>
π LICENSE π
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
and that's the whole page, babes π
this was perl v5.42.3, dated 2026-08-02 β shoutout to that version and that date for real, they're the moment. mwah. π«Άβ¨
π¦ where this page comes from
- fedora 43: perl-Data-Entropy 0.010-1.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- fedora 44: perl-Data-Entropy 0.010-1.fc44 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms