ParagonIE_Sodium_Compat::randombytes_uniform

Advertisement

Summery Summery

Generate an integer between 0 and $range (non-inclusive).

Syntax Syntax

ParagonIE_Sodium_Compat::randombytes_uniform( int $range )

Parameters Parameters

$range

(Required)

Return Return

(int)

Source Source

File: wp-includes/sodium_compat/src/Compat.php

    public static function randombytes_uniform($range)
    {
        /* Type checks: */
        if (!is_int($range)) {
            if (is_numeric($range)) {
                $range = (int) $range;
            } else {
                throw new TypeError(
                    'Argument 1 must be an integer, ' . gettype($range) . ' given.'
                );
            }
        }
        if (self::use_fallback('randombytes_uniform')) {
            return (int) call_user_func('\\Sodium\\randombytes_uniform', $range);
        }
        return random_int(0, $range - 1);
    }

Advertisement

Advertisement

Leave a Reply