validateLength($length); $wasCryptographicallyStrong = false; $binaryString = openssl_random_pseudo_bytes($length, $wasCryptographicallyStrong); if ($binaryString === false) { throw new FacebookSDKException(static::ERROR_MESSAGE . 'openssl_random_pseudo_bytes() returned an unknown error.'); } if ($wasCryptographicallyStrong !== true) { throw new FacebookSDKException(static::ERROR_MESSAGE . 'openssl_random_pseudo_bytes() returned a pseudo-random string but it was not cryptographically secure and cannot be used.'); } return $this->binToHex($binaryString, $length); } }