generateRandomString() публичный статический Метод

Returns a random string with alpha-numeric characters.
public static generateRandomString ( integer $count, string $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789' ) : string
$count integer Number of characters to generate
$characters string Allowed characters, defaults to alpha-numeric (a-zA-Z0-9)
Результат string A random string
 /**
  * Generates a new key & saves it encrypted with a hashing strategy
  *
  * @param string $name
  * @return string
  * @throws SecurityException
  */
 public function generateKey($name)
 {
     if (strlen($name) === 0) {
         throw new SecurityException('Required name argument was empty', 1334215474);
     }
     $password = UtilityAlgorithms::generateRandomString($this->passwordGenerationLength);
     $this->persistKey($name, $password);
     return $password;
 }
 /**
  * @test
  * @dataProvider randomStringCharactersDataProvider
  */
 public function generateRandomStringGeneratesOnlyDefinedCharactersRange($regularExpression, $charactersClass)
 {
     $this->assertRegExp($regularExpression, Algorithms::generateRandomString(64, $charactersClass));
 }
 /**
  * Creates a BCrypt hash
  *
  * @param string $password   The plaintext password to hash
  * @param string $staticSalt Optional static salt that will not be stored in the hashed password
  * @return string the result of the crypt() call
  */
 public function hashPassword($password, $staticSalt = null)
 {
     $dynamicSalt = UtilityAlgorithms::generateRandomString(22, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./');
     return crypt($password, '$2a$' . $this->cost . '$' . $dynamicSalt);
 }
Пример #4
0
 /**
  * Generates and propagates a new session ID and transfers all existing data
  * to the new session.
  *
  * @return string The new session ID
  * @throws Exception\SessionNotStartedException
  * @throws Exception\OperationNotSupportedException
  * @api
  */
 public function renewId()
 {
     if ($this->started !== true) {
         throw new Exception\SessionNotStartedException('Tried to renew the session identifier, but the session has not been started yet.', 1351182429);
     }
     if ($this->remote === true) {
         throw new Exception\OperationNotSupportedException(sprintf('Tried to renew the session identifier on a remote session (%s).', $this->sessionIdentifier), 1354034230);
     }
     $this->removeSessionMetaDataCacheEntry($this->sessionIdentifier);
     $this->sessionIdentifier = Algorithms::generateRandomString(32);
     $this->writeSessionMetaDataCacheEntry();
     $this->sessionCookie->setValue($this->sessionIdentifier);
     return $this->sessionIdentifier;
 }