This avoids random_bytes polyfills used on older versions of PHP or
HHVM. HHVM has had random_bytes longer than PHP so treat it separately.
Bug: T143788
Change-Id: Ic9e511ccc043d50e0a9051cdfe069c27e4f4c339
// On Linux, getrandom syscall will be used if available.
// On Windows CryptGenRandom will always be used
// On other platforms, /dev/urandom will be used.
+ // Avoids polyfills from before php 7.0
// All error situations will throw Exceptions and or Errors
- if ( function_exists( 'random_bytes' ) ) {
+ if ( PHP_VERSION_ID >= 70000
+ || ( defined( 'HHVM_VERSION_ID' ) && HHVM_VERSION_ID >= 31101 )
+ ) {
$rem = $bytes - strlen( $buffer );
$buffer .= random_bytes( $rem );
}