2017 © Pedro Peláez
 

library password-generator

Password Generator Library

image

hackzilla/password-generator

Password Generator Library

  • Saturday, April 7, 2018
  • by hackzilla
  • Repository
  • 4 Watchers
  • 120 Stars
  • 299,078 Installations
  • PHP
  • 8 Dependents
  • 1 Suggesters
  • 17 Forks
  • 2 Open issues
  • 30 Versions
  • 10 % Grown

The README.md

Password Generator Library

Simple library for generating random passwords., (*1)

Latest Stable Version Total Downloads Latest Unstable Version License, (*2)

Requirements

  • PHP >= 8.0
  • ext-mbstring

Installation

Install Composer, (*3)

curl -sS https://getcomposer.org/installer | php
mv composer.phar /usr/local/bin/composer

Now tell composer to download the library by running the command:, (*4)

``` bash $ composer require hackzilla/password-generator, (*5)


Composer will add the library to your composer.json file and install it into your project's `vendor/hackzilla` directory. ## Simple Usage ```php use Hackzilla\PasswordGenerator\Generator\ComputerPasswordGenerator; $generator = new ComputerPasswordGenerator(); $generator ->setOptionValue(ComputerPasswordGenerator::OPTION_UPPER_CASE, true) ->setOptionValue(ComputerPasswordGenerator::OPTION_LOWER_CASE, true) ->setOptionValue(ComputerPasswordGenerator::OPTION_NUMBERS, true) ->setOptionValue(ComputerPasswordGenerator::OPTION_SYMBOLS, false) ; $password = $generator->generatePassword();

More Passwords Usage

If you want to generate 10 passwords that are 12 characters long., (*6)

use Hackzilla\PasswordGenerator\Generator\ComputerPasswordGenerator;

$generator = new ComputerPasswordGenerator();

$generator
  ->setUppercase()
  ->setLowercase()
  ->setNumbers()
  ->setSymbols(false)
  ->setLength(12);

$password = $generator->generatePasswords(10);

Hybrid Password Generator Usage

use Hackzilla\PasswordGenerator\Generator\HybridPasswordGenerator;

$generator = new HybridPasswordGenerator();

$generator
  ->setUppercase()
  ->setLowercase()
  ->setNumbers()
  ->setSymbols(false)
  ->setSegmentLength(3)
  ->setSegmentCount(4)
  ->setSegmentSeparator('-');

$password = $generator->generatePasswords(10);

If you can think of a better name for this password generator then let me know., (*7)

The segment separator will be remove from the possible characters., (*8)

Human Password Generator Usage

use Hackzilla\PasswordGenerator\Generator\HumanPasswordGenerator;

$generator = new HumanPasswordGenerator();

$generator
  ->setWordList('/usr/share/dict/words')
  ->setWordCount(3)
  ->setWordSeparator('-');

$password = $generator->generatePasswords(10);

Requirement Password Generator Usage

use Hackzilla\PasswordGenerator\Generator\RequirementPasswordGenerator;

$generator = new RequirementPasswordGenerator();

$generator
  ->setLength(16)
  ->setOptionValue(RequirementPasswordGenerator::OPTION_UPPER_CASE, true)
  ->setOptionValue(RequirementPasswordGenerator::OPTION_LOWER_CASE, true)
  ->setOptionValue(RequirementPasswordGenerator::OPTION_NUMBERS, true)
  ->setOptionValue(RequirementPasswordGenerator::OPTION_SYMBOLS, true)
  ->setMinimumCount(RequirementPasswordGenerator::OPTION_UPPER_CASE, 2)
  ->setMinimumCount(RequirementPasswordGenerator::OPTION_LOWER_CASE, 2)
  ->setMinimumCount(RequirementPasswordGenerator::OPTION_NUMBERS, 2)
  ->setMinimumCount(RequirementPasswordGenerator::OPTION_SYMBOLS, 2)
  ->setMaximumCount(RequirementPasswordGenerator::OPTION_UPPER_CASE, 8)
  ->setMaximumCount(RequirementPasswordGenerator::OPTION_LOWER_CASE, 8)
  ->setMaximumCount(RequirementPasswordGenerator::OPTION_NUMBERS, 8)
  ->setMaximumCount(RequirementPasswordGenerator::OPTION_SYMBOLS, 8)
;

$password = $generator->generatePassword();

A limit can be removed by passing null, (*9)

$generator
  ->setMinimumCount(RequirementPasswordGenerator::OPTION_UPPER_CASE, null)
  ->setMaximumCount(RequirementPasswordGenerator::OPTION_UPPER_CASE, null)
;

When setting the minimum and maximum values, be careful of unachievable settings., (*10)

For example the following will end up in an infinite loop., (*11)

$generator
  ->setLength(4)
  ->setOptionValue(RequirementPasswordGenerator::OPTION_UPPER_CASE, true)
  ->setOptionValue(RequirementPasswordGenerator::OPTION_LOWER_CASE, false)
  ->setMinimumCount(RequirementPasswordGenerator::OPTION_UPPER_CASE, 5)
  ->setMaximumCount(RequirementPasswordGenerator::OPTION_LOWER_CASE, 1)
;

For the moment you can call $generator->validLimits() to test whether the counts will cause problems. If the method returns true, then you can proceed. If false, then generatePassword() will likely cause an infinite loop., (*12)

Example Implementations

  • Password Generator App [https://github.com/hackzilla/password-generator-app]
  • Password Generator Bundle [https://github.com/hackzilla/password-generator-bundle]

Random Note

Since version 1.5.0, the library depends on the presence of random_int which is found in PHP 7.0+, (*13)

Contributions and Issues

See all contributors on GitHub., (*14)

Please report issues using GitHub's issue tracker: GitHub Repo, (*15)

If you find this project useful, consider buying me a coffee., (*16)

License

This bundle is released under the MIT license. See the LICENSE file for details., (*17)

The Versions

07/04 2018

dev-master

9999999-dev

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

15/07 2017

1.4.0

1.4.0.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

24/07 2016

dev-develop

dev-develop

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

24/07 2016

1.3.0

1.3.0.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

24/07 2016

dev-release/1.3.0

dev-release/1.3.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

06/05 2016

1.2.0

1.2.0.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

03/05 2016

dev-feature/human-length

dev-feature/human-length

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

25/04 2016

1.1.1

1.1.1.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

17/07 2015

1.1.0

1.1.0.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

10/01 2015

1.0.1

1.0.1.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

04/01 2015

1.0

1.0.0.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

03/01 2015

1.0-alpha3

1.0.0.0-alpha3

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

01/01 2015

1.0-alpha2

1.0.0.0-alpha2

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

01/01 2015

1.0-alpha

1.0.0.0-alpha

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

The Development Requires

22/12 2014

0.8

0.8.0.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

12/10 2014

0.7.5

0.7.5.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

11/10 2014

0.7.4

0.7.4.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

11/10 2014

0.7.3

0.7.3.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

09/10 2014

0.7.2

0.7.2.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

07/10 2014

0.7.1

0.7.1.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

06/10 2014

0.7

0.7.0.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

20/05 2014

0.6.2

0.6.2.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

06/05 2014

0.6.1

0.6.1.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

05/05 2014

0.6

0.6.0.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

27/04 2014

0.5

0.5.0.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

21/04 2014

0.4.1

0.4.1.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

21/04 2014

0.4

0.4.0.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

17/04 2014

0.3

0.3.0.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

15/04 2014

0.2

0.2.0.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2

 

12/04 2014

0.1

0.1.0.0

Password Generator Library

  Sources   Download

MIT

The Requires

  • php >=5.3.2