validateLength($length); $stream = fopen('/dev/urandom', 'rb'); if (!is_resource($stream)) { throw new FacebookSDKException( static::ERROR_MESSAGE . 'Unable to open stream to /dev/urandom.' ); } if (!defined('HHVM_VERSION')) { stream_set_read_buffer($stream, 0); } $binaryString = fread($stream, $length); fclose($stream); if (!$binaryString) { throw new FacebookSDKException( static::ERROR_MESSAGE . 'Stream to /dev/urandom returned no data.' ); } return $this->binToHex($binaryString, $length); } }