You are here

static function handler::generateRandom in OAuth2 Login 8

File

src/handler.php, line 10

Class

handler

Namespace

Drupal\oauth2_login

Code

static function generateRandom($length = 30) {
  $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
  $charactersLength = strlen($characters);
  $randomString = '';
  for ($i = 0; $i < $length; $i++) {
    $randomString .= $characters[rand(0, $charactersLength - 1)];
  }
  return $randomString;
}