Hackzilla\PasswordGenerator\Generator\ComputerPasswordGenerator::generatePassword PHP Method

generatePassword() public method

Generate one password based on options.
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;
    }

Usage Example

 /**
  * 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;
 }
All Usage Examples Of Hackzilla\PasswordGenerator\Generator\ComputerPasswordGenerator::generatePassword