ParagonIE_Sodium_Compat::randombytes_buf

Advertisement

Summery Summery

Generate a string of bytes from the kernel’s CSPRNG.

Syntax Syntax

ParagonIE_Sodium_Compat::randombytes_buf( int $numBytes )

Description Description

Proudly uses /dev/urandom (if getrandom(2) is not available).

Parameters Parameters

$numBytes

(Required)

Return Return

(string)

Source Source

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

    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.'
                );
            }
        }
        if (self::use_fallback('randombytes_buf')) {
            return (string) call_user_func('\\Sodium\\randombytes_buf', $numBytes);
        }
        return random_bytes($numBytes);
    }

Advertisement

Advertisement

Leave a Reply