public static function ParagonIE_Sodium_Compat::randombytes_buf in Automatic Updates 8
Same name and namespace in other branches
- 7 vendor/paragonie/sodium_compat/src/Compat.php \ParagonIE_Sodium_Compat::randombytes_buf()
Generate a string of bytes from the kernel's CSPRNG. Proudly uses /dev/urandom (if getrandom(2) is not available).
Parameters
int $numBytes:
Return value
string
Throws
Exception
TypeError
3 calls to ParagonIE_Sodium_Compat::randombytes_buf()
- ParagonIE_Sodium_Compat::crypto_kx_keypair in vendor/
paragonie/ sodium_compat/ src/ Compat.php - php72compat.php in vendor/
paragonie/ sodium_compat/ lib/ php72compat.php - sodium_compat.php in vendor/
paragonie/ sodium_compat/ lib/ sodium_compat.php
File
- vendor/
paragonie/ sodium_compat/ src/ Compat.php, line 3393
Class
Code
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);
}