public generatePassword ( ) : string | ||
return | string | password |
public function generatePassword()
{
$characterList = $this->getCharacterList()->getCharacters();
$characters = \strlen($characterList);
$password = '';
$length = $this->getLength();
for ($i = 0; $i < $length; ++$i) {
$password .= $characterList[$this->randomInteger(0, $characters - 1)];
}
return $password;
}
/** * Generate one password based on options. * * @return string password * @throws ImpossibleMinMaxLimitsException * @throws \Hackzilla\PasswordGenerator\Exception\CharactersNotFoundException */ public function generatePassword() { if ($this->dirtyCheck) { if (!$this->validLimits()) { throw new ImpossibleMinMaxLimitsException(); } $this->dirtyCheck = false; } do { $password = parent::generatePassword(); } while (!$this->validatePassword($password)); return $password; }