Crypt::OpenSSL::Random - OpenSSL/LibreSSL pseudo-random number generator access
| Use Case | Command | Description |
|---|---|---|
| Seed PRNG with random data | Crypt::OpenSSL::Random::random_seed($data) | 🌱 Seeds the PRNG with a string of bytes; returns true if sufficient seeding. |
| Seed PRNG from EGD daemon | Crypt::OpenSSL::Random::random_egd("/path") | 🔌 Seeds from entropy gathering daemon; returns bytes read or -1. (Not on LibreSSL) |
| Check PRNG seeding status | Crypt::OpenSSL::Random::random_status() | ✅ Returns true if PRNG has sufficient seeding. |
| Get cryptographically strong random bytes | Crypt::OpenSSL::Random::random_bytes(10) | 🔒 Returns 10 strong random bytes, or false if insufficient seed. |
| Get pseudo-random bytes (non-cryptographic) | Crypt::OpenSSL::Random::random_pseudo_bytes(10) | 🔓 Returns 10 pseudo-random bytes (not necessarily unpredictable). |
use Crypt::OpenSSL::Random;
Crypt::OpenSSL::Random::random_seed($good_random_data);
Crypt::OpenSSL::Random::random_egd("/tmp/entropy");
Crypt::OpenSSL::Random::random_status() or
die "Unable to sufficiently seed the random number generator".
my $ten_good_random_bytes = Crypt::OpenSSL::Random::random_bytes(10);
my $ten_ok_random_bytes = Crypt::OpenSSL::Random::random_pseudo_bytes(10);
Crypt::OpenSSL::Random provides the ability to seed and query the OpenSSL and LibreSSL library's pseudo-random number generators.
Note: On LibreSSL random_egd() is not defined.
None by default.
random_bytes, but the resulting sequence of bytes are not necessarily unpredictable. They can be used for non-cryptographic purposes and for certain purposes in cryptographic protocols, but usually not for key generation etc.libressl considers this function insecure, so with libressl this function does not exist.Because of the internal workings of OpenSSL's random library, the pseudo-random number generator (PRNG) accessed by Crypt::OpenSSL::Random will be different than the one accessed by any other perl module. Hence, to use a module such as Crypt::OpenSSL::Random, you will need to seed the PRNG used there from one used here. This class is still advantageous, however, as it centralizes other methods, such as random_egd, in one place.
Ian Robertson, iroberts@cpan.com
Now maintained by Reini Urban, rurban@cpan.org
This module is available under the same licences as perl, the Artistic license and the GPL.
perl(1), rand(3), RAND_add(3), RAND_egd(3), RAND_bytes(3).
perl v5.34.0 2022-02-06 Random(3pm)
Generated by phpman v4.9.26-1-g511901d Author: Che Dong Under GNU General Public License
2026-08-09 09:03 @2600:1f28:365:80b0:50b3:453e:ff52:20f7
CrawledBy CCBot/2.0 (https://commoncrawl.org/faq/)
Enhanced by LLM: deepseek-v4-flash / taotoken.net / www.chedong.com - original format