{
    "mode": "perldoc",
    "parameter": "Crypt::OpenSSL::Random",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Crypt%3A%3AOpenSSL%3A%3ARandom/json",
    "generated": "2026-06-13T00:58:31Z",
    "synopsis": "use Crypt::OpenSSL::Random;\nCrypt::OpenSSL::Random::randomseed($goodrandomdata);\nCrypt::OpenSSL::Random::randomegd(\"/tmp/entropy\");\nCrypt::OpenSSL::Random::randomstatus() or\ndie \"Unable to sufficiently seed the random number generator\".\nmy $tengoodrandombytes = Crypt::OpenSSL::Random::randombytes(10);\nmy $tenokrandombytes = Crypt::OpenSSL::Random::randompseudobytes(10);",
    "sections": {
        "NAME": {
            "content": "Crypt::OpenSSL::Random - OpenSSL/LibreSSL pseudo-random number generator access\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Crypt::OpenSSL::Random;\n\nCrypt::OpenSSL::Random::randomseed($goodrandomdata);\nCrypt::OpenSSL::Random::randomegd(\"/tmp/entropy\");\nCrypt::OpenSSL::Random::randomstatus() or\ndie \"Unable to sufficiently seed the random number generator\".\n\nmy $tengoodrandombytes = Crypt::OpenSSL::Random::randombytes(10);\nmy $tenokrandombytes = Crypt::OpenSSL::Random::randompseudobytes(10);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "\"Crypt::OpenSSL::Random\" provides the ability to seed and query the OpenSSL and LibreSSL\nlibrary's pseudo-random number generators.\n\nNote: On LibreSSL \"randomegd()\" is not defined.\n\nEXPORT\nNone by default.\n",
            "subsections": []
        },
        "Static Methods": {
            "content": "randombytes (IV numbytes)\nThis function, returns a specified number of cryptographically strong pseudo-random bytes\nfrom the PRNG. If the PRNG has not been seeded with enough randomness to ensure an\nunpredictable byte sequence, then a false value is returned.\n\nrandompseudobytes (IV numbytes)\nThis function, is similar to \"randombytes\", but the resulting sequence of bytes are not\nnecessarily unpredictable. They can be used for non-cryptographic purposes and for certain\npurposes in cryptographic protocols, but usually not for key generation etc.\n\nrandomseed (PV randombytesstring)\nThis function seeds the PRNG with a supplied string of bytes. It returns true if the PRNG\nhas sufficient seeding. Note: calling this function with non-random bytes is of limited\nvalue at best!\n\nrandomegd (PV egdstring)\nThis function seeds the PRNG with data from the specified entropy gathering daemon. Returns\nthe number of bytes read from the daemon on success, or -1 if not enough bytes were read, or\nif the connection to the daemon failed.\n\n\"libressl\" considers this function insecure, so with libressl this function does not exist.\n\nrandomstatus ()\nThis function returns true if the PRNG has sufficient seeding.\n",
            "subsections": []
        },
        "BUGS": {
            "content": "Because of the internal workings of OpenSSL's random library, the pseudo-random number generator\n(PRNG) accessed by Crypt::OpenSSL::Random will be different than the one accessed by any other\nperl module. Hence, to use a module such as Crypt::OpenSSL::Random, you will need to seed the\nPRNG used there from one used here. This class is still advantageous, however, as it centralizes\nother methods, such as \"randomegd\", in one place.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Ian Robertson, \"iroberts@cpan.com\"\n\nNow maintained by Reini Urban, \"rurban@cpan.org\"\n",
            "subsections": []
        },
        "LICENSE": {
            "content": "This module is available under the same licences as perl, the Artistic license and the GPL.\n",
            "subsections": []
        },
        "SEE ALSO": {
            "content": "",
            "subsections": [
                {
                    "name": "perl",
                    "content": ""
                }
            ]
        }
    },
    "summary": "Crypt::OpenSSL::Random - OpenSSL/LibreSSL pseudo-random number generator access",
    "flags": [],
    "examples": [],
    "see_also": []
}