- if ( strlen( $buffer ) < $bytes ) {
- if ( function_exists( 'openssl_random_pseudo_bytes' ) ) {
- $rem = $bytes - strlen( $buffer );
- $openssl_bytes = openssl_random_pseudo_bytes( $rem, $openssl_strong );
- if ( $openssl_bytes === false ) {
- $this->logger->debug( "openssl_random_pseudo_bytes returned false." );
- } else {
- $buffer .= $openssl_bytes;
- $this->logger->debug( "openssl_random_pseudo_bytes generated " .
- strlen( $openssl_bytes ) . " bytes of " .
- ( $openssl_strong ? "strong" : "weak" ) . " randomness." );
- }
- if ( strlen( $buffer ) >= $bytes ) {
- // openssl tells us if the random source was strong, if some of our data was generated
- // using it use it's say on whether the randomness is strong
- $this->strong = !!$openssl_strong;
- }
+ if ( strlen( $buffer ) < $bytes && function_exists( 'openssl_random_pseudo_bytes' ) ) {
+ $rem = $bytes - strlen( $buffer );
+ $openssl_strong = false;
+ $openssl_bytes = openssl_random_pseudo_bytes( $rem, $openssl_strong );
+ if ( $openssl_bytes === false ) {
+ $this->logger->debug( "openssl_random_pseudo_bytes returned false." );
+ } else {
+ $buffer .= $openssl_bytes;
+ $this->logger->debug( "openssl_random_pseudo_bytes generated " .
+ strlen( $openssl_bytes ) . " bytes of " .
+ ( $openssl_strong ? "strong" : "weak" ) . " randomness." );
+ }
+ if ( strlen( $buffer ) >= $bytes ) {
+ // openssl tells us if the random source was strong, if some of our data was generated
+ // using it use it's say on whether the randomness is strong
+ $this->strong = !!$openssl_strong;