ParagonIE_Sodium_Compat::randombytes_buf()public staticWP 1.0

Generate a string of bytes from the kernel's CSPRNG. Proudly uses /dev/urandom (if getrandom(2) is not available).

{} Это метод класса: ParagonIE_Sodium_Compat{}

Хуков нет.

Возвращает

Строку.

Использование

$result = ParagonIE_Sodium_Compat::randombytes_buf( $numBytes );
$numBytes(int) (обязательный)
-

Код ParagonIE_Sodium_Compat::randombytes_buf() WP 6.0.2

public static function randombytes_buf($numBytes)
{
    /* Type checks: */
    if (!is_int($numBytes)) {
        if (is_numeric($numBytes)) {
            $numBytes = (int) $numBytes;
        } else {
            throw new TypeError(
                'Argument 1 must be an integer, ' . gettype($numBytes) . ' given.'
            );
        }
    }
    /** @var positive-int $numBytes */
    if (self::use_fallback('randombytes_buf')) {
        return (string) call_user_func('\\Sodium\\randombytes_buf', $numBytes);
    }
    if ($numBytes < 0) {
        throw new SodiumException("Number of bytes must be a positive integer");
    }
    return random_bytes($numBytes);
}