예제 #1
0
 /**
  * Generates a new key & saves it encrypted with a hashing strategy
  *
  * @param string $name
  * @return string
  * @throws \TYPO3\FLOW3\Security\Exception
  */
 public function generateKey($name)
 {
     if (strlen($name) === 0) {
         throw new \TYPO3\FLOW3\Security\Exception('Required name argument was empty', 1334215474);
     }
     $password = \TYPO3\FLOW3\Utility\Algorithms::generateRandomString($this->passwordGenerationLength);
     $this->persistKey($name, $password);
     return $password;
 }
예제 #2
0
 /**
  * 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 = \TYPO3\FLOW3\Utility\Algorithms::generateRandomString(22, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./');
     return crypt($password, '$2a$' . $this->cost . '$' . $dynamicSalt);
 }