You are here

private function AuthController::getRandomBytes in Auth0 Single Sign On 8.2

Same name and namespace in other branches
  1. 8 src/Controller/AuthController.php \Drupal\auth0\Controller\AuthController::getRandomBytes()

Get random bytes string.

Parameters

int $nbBytes: The number of bytes to generate.

Return value

string The generated string.

Throws

\Exception

1 call to AuthController::getRandomBytes()
AuthController::generatePassword in src/Controller/AuthController.php
Generate a random password.

File

src/Controller/AuthController.php, line 951
Contains \Drupal\auth0\Controller\AuthController.

Class

AuthController
Controller routines for auth0 authentication.

Namespace

Drupal\auth0\Controller

Code

private function getRandomBytes($nbBytes = 32) {
  $bytes = openssl_random_pseudo_bytes($nbBytes, $strong);
  if (FALSE !== $bytes && TRUE === $strong) {
    return $bytes;
  }
  else {
    throw new \Exception("Unable to generate secure token from OpenSSL.");
  }
}