{
    "content": [
        {
            "type": "text",
            "text": "# Crypt::PRNG (perldoc)\n\n## NAME\n\nCrypt::PRNG - Cryptographically secure random number generator\n\n## SYNOPSIS\n\n### Functional interface:\nuse Crypt::PRNG qw(randombytes randombyteshex randombytesb64 randombytesb64u\nrandomstring randomstringfrom rand irand);\n$octets = randombytes(45);\n$hexstring = randombyteshex(45);\n$base64string = randombytesb64(45);\n$base64urlstring = randombytesb64u(45);\n$alphanumericstring = randomstring(30);\n$string = randomstringfrom('ACGT', 64);\n$floatingpointnumber0to1 = rand;\n$floatingpointnumber0to88 = rand(88);\n$unsigned32bitint = irand;\n### OO interface:\nuse Crypt::PRNG;\n$prng = Crypt::PRNG->new;\n#or\n$prng = Crypt::PRNG->new(\"RC4\");\n#or\n$prng = Crypt::PRNG->new(\"RC4\", \"some data used for seeding PRNG\");\n$octets = $prng->bytes(45);\n$hexstring = $prng->byteshex(45);\n$base64string = $prng->bytesb64(45);\n$base64urlstring = $prng->bytesb64u(45);\n$alphanumericstring = $prng->string(30);\n$string = $prng->stringfrom('ACGT', 64);\n$floatingpointnumber0to1 = $prng->double;\n$floatingpointnumber0to88 = $prng->double(88);\n$unsigned32bitint = $prng->int32;\n\n## DESCRIPTION\n\nProvides an interface to the ChaCha20 based pseudo random number generator (thread-safe and\nfork-safe).\n\n## Sections\n\n- **NAME**\n- **SYNOPSIS**\n- **DESCRIPTION**\n- **FUNCTIONS**\n- **METHODS**\n- **SEE ALSO**\n\nUse structuredContent.sections for detailed options, examples, and full documentation.\n"
        }
    ],
    "structuredContent": {
        "command": "Crypt::PRNG",
        "section": "",
        "mode": "perldoc",
        "summary": "Crypt::PRNG - Cryptographically secure random number generator",
        "synopsis": "### Functional interface:\nuse Crypt::PRNG qw(randombytes randombyteshex randombytesb64 randombytesb64u\nrandomstring randomstringfrom rand irand);\n$octets = randombytes(45);\n$hexstring = randombyteshex(45);\n$base64string = randombytesb64(45);\n$base64urlstring = randombytesb64u(45);\n$alphanumericstring = randomstring(30);\n$string = randomstringfrom('ACGT', 64);\n$floatingpointnumber0to1 = rand;\n$floatingpointnumber0to88 = rand(88);\n$unsigned32bitint = irand;\n### OO interface:\nuse Crypt::PRNG;\n$prng = Crypt::PRNG->new;\n#or\n$prng = Crypt::PRNG->new(\"RC4\");\n#or\n$prng = Crypt::PRNG->new(\"RC4\", \"some data used for seeding PRNG\");\n$octets = $prng->bytes(45);\n$hexstring = $prng->byteshex(45);\n$base64string = $prng->bytesb64(45);\n$base64urlstring = $prng->bytesb64u(45);\n$alphanumericstring = $prng->string(30);\n$string = $prng->stringfrom('ACGT', 64);\n$floatingpointnumber0to1 = $prng->double;\n$floatingpointnumber0to88 = $prng->double(88);\n$unsigned32bitint = $prng->int32;",
        "tldr_summary": null,
        "tldr_examples": [],
        "tldr_source": null,
        "flags": [],
        "examples": [],
        "see_also": [],
        "section_outline": [
            {
                "name": "NAME",
                "lines": 2,
                "subsections": []
            },
            {
                "name": "SYNOPSIS",
                "lines": 33,
                "subsections": []
            },
            {
                "name": "DESCRIPTION",
                "lines": 3,
                "subsections": []
            },
            {
                "name": "FUNCTIONS",
                "lines": 48,
                "subsections": []
            },
            {
                "name": "METHODS",
                "lines": 68,
                "subsections": []
            },
            {
                "name": "SEE ALSO",
                "lines": 2,
                "subsections": []
            }
        ],
        "sections": {
            "NAME": {
                "content": "Crypt::PRNG - Cryptographically secure random number generator\n",
                "subsections": []
            },
            "SYNOPSIS": {
                "content": "### Functional interface:\nuse Crypt::PRNG qw(randombytes randombyteshex randombytesb64 randombytesb64u\nrandomstring randomstringfrom rand irand);\n\n$octets = randombytes(45);\n$hexstring = randombyteshex(45);\n$base64string = randombytesb64(45);\n$base64urlstring = randombytesb64u(45);\n$alphanumericstring = randomstring(30);\n$string = randomstringfrom('ACGT', 64);\n$floatingpointnumber0to1 = rand;\n$floatingpointnumber0to88 = rand(88);\n$unsigned32bitint = irand;\n\n### OO interface:\nuse Crypt::PRNG;\n\n$prng = Crypt::PRNG->new;\n#or\n$prng = Crypt::PRNG->new(\"RC4\");\n#or\n$prng = Crypt::PRNG->new(\"RC4\", \"some data used for seeding PRNG\");\n\n$octets = $prng->bytes(45);\n$hexstring = $prng->byteshex(45);\n$base64string = $prng->bytesb64(45);\n$base64urlstring = $prng->bytesb64u(45);\n$alphanumericstring = $prng->string(30);\n$string = $prng->stringfrom('ACGT', 64);\n$floatingpointnumber0to1 = $prng->double;\n$floatingpointnumber0to88 = $prng->double(88);\n$unsigned32bitint = $prng->int32;\n",
                "subsections": []
            },
            "DESCRIPTION": {
                "content": "Provides an interface to the ChaCha20 based pseudo random number generator (thread-safe and\nfork-safe).\n",
                "subsections": []
            },
            "FUNCTIONS": {
                "content": "randombytes\n$octets = randombytes($length);\n\nReturns $length random octects.\n\nrandombyteshex\n$hexstring = randombyteshex($length);\n\nReturns $length random octects encoded as hexadecimal string.\n\nrandombytesb64\n$base64string = randombytesb64($length);\n\nReturns $length random octects Base64 encoded.\n\nrandombytesb64u\n$base64urlstring = randombytesb64u($length);\n\nReturns $length random octects Base64 URL Safe (RFC 4648 section 5) encoded.\n\nrandomstringfrom\n$string = randomstringfrom($range, $length);\n#e.g.\n$string = randomstringfrom(\"ABCD\", 10);\n\nReturns a random string made of $length chars randomly chosen from $range string.\n\nrandomstring\n$alphanumericstring = randomstring($length);\n#or\n$alphanumericstring = randomstring;  # default length = 20\n\nSimilar to randomstringfrom, only $range is fixed to\n'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'.\n\nrand\n$n = rand;\n#or\n$n = rand($limit);\n\nReturns a random floating point number from range \"[0,1)\" (if called without parameter) or\n\"[0,$limit)\".\n\nirand\n$i = irand;\n\nReturns a random unsigned 32bit integer - range \"0 .. 0xFFFFFFFF\".\n",
                "subsections": []
            },
            "METHODS": {
                "content": "new\n$prng = Crypt::PRNG->new;\n#or\n$prng = Crypt::PRNG->new($alg);\n#or\n$prng = Crypt::PRNG->new($alg, $seed);\n\n# $alg  ... algorithm name 'Frotuna' (DEFAULT), 'RC4', 'Sober128' or 'Yarrow'\n# $seed ... will be used as an initial entropy for seeding PRNG\n\nIf $seed is not specified the PRNG is automatically seeded with 32bytes random data taken from\n\"/dev/random\" (UNIX) or \"CryptGenRandom\" (Win32)\n\naddentropy\n$prng->addentropy($randomdata);\n#or\n$prng->addentropy();\n\nIf called without parameter it uses 32bytes random data taken from \"/dev/random\" (UNIX) or\n\"CryptGenRandom\" (Win32).\n\nBEWARE: you probably do not need this function at all as the module does automatic seeding on\ninitialization as well as reseeding after fork and thread creation.\n\nbytes\n$octets = $prng->bytes($length);\n\nSee randombytes\n\nbyteshex\n$hexstring = $prng->byteshex($length);\n\nSee randombyteshex\n\nbytesb64\n$base64string = $prng->bytesb64($length);\n\nSee randombytesb64\n\nbytesb64u\n$base64urlstring = $prng->bytesb64u($length);\n\nSee randombytesb64u\n\nstring\n$alphanumericstring = $prng->string($length);\n#or\n$alphanumericstring = $prng->string;\n\nSee randomstring\n\nstringfrom\n$string = $prng->stringfrom($range, $length);\n\nSee randomstringfrom\n\ndouble\n$n = $prng->double;\n#or\n$n = $prng->double($limit);\n\nSee rand\n\nint32\n$i = $prng->int32;\n\nSee irand\n",
                "subsections": []
            },
            "SEE ALSO": {
                "content": "Crypt::PRNG::Fortuna, Crypt::PRNG::RC4, Crypt::PRNG::Sober128, Crypt::PRNG::Yarrow\n",
                "subsections": []
            }
        }
    }
}