All Projects → hackzilla → Password Generator

hackzilla / Password Generator

PHP Library to generate random passwords

Projects that are alternatives of or similar to Password Generator

Package Builder
📦 A composer package builder.
Stars: ✭ 174 (-20.18%)
Mutual labels:  composer
Laravel Shield
A HTTP basic auth middleware for Laravel
Stars: ✭ 193 (-11.47%)
Mutual labels:  composer
Openapi Sdk Php Client
Official repository of the Alibaba Cloud Client for PHP
Stars: ✭ 206 (-5.5%)
Mutual labels:  composer
Docker
Composer in Docker
Stars: ✭ 180 (-17.43%)
Mutual labels:  composer
Laravel Deployment
📗[WIP] 追求质量的 Laravel 应用部署上线课程。
Stars: ✭ 190 (-12.84%)
Mutual labels:  composer
Wordpress Heroku
This project is a template for installing and running WordPress 5.x on Heroku.
Stars: ✭ 198 (-9.17%)
Mutual labels:  composer
Security Checker
PHP frontend for security.symfony.com
Stars: ✭ 2,036 (+833.94%)
Mutual labels:  composer
Pws
Command-Line Password Safe 🔐︎
Stars: ✭ 208 (-4.59%)
Mutual labels:  password-generator
Nebula
Nebula is a minimalistic and easy to use administration tool for Laravel applications, made with Laravel, Alpine.js, and Tailwind CSS.
Stars: ✭ 190 (-12.84%)
Mutual labels:  composer
Magento Composer Installer
Composer installer for Magento modules
Stars: ✭ 204 (-6.42%)
Mutual labels:  composer
Wpstarter
Easily bootstrap whole site Composer packages for WordPress.
Stars: ✭ 182 (-16.51%)
Mutual labels:  composer
Alidayu
阿里大于(鱼)API接口-SDK
Stars: ✭ 186 (-14.68%)
Mutual labels:  composer
Alfred Pwgen
Generate passwords with Alfred
Stars: ✭ 201 (-7.8%)
Mutual labels:  password-generator
Composer Service
Composer as a service
Stars: ✭ 175 (-19.72%)
Mutual labels:  composer
Bitrix Project
Заготовка 1C Bitrix проекта: автозагрузка, композер, базовые ООП компоненты, миграции, модели, современный фронтенд стек, инструменты для деплоя.
Stars: ✭ 207 (-5.05%)
Mutual labels:  composer
Composer Preload
Preload your sweet sweet code to opcache with a composer command, making your code faster to run.
Stars: ✭ 173 (-20.64%)
Mutual labels:  composer
Composer Patches
Applies a patch from a local or remote file to any package that is part of a given composer project. Patches can be defined both on project and on package level. Optional support for patch versioning, sequencing, custom patch applier configuration and composer command for testing/troubleshooting patches.
Stars: ✭ 196 (-10.09%)
Mutual labels:  composer
Vscode Versionlens
This project has moved to gitlab
Stars: ✭ 218 (+0%)
Mutual labels:  composer
Webmail Lite 8
Open-source webmail script for existing IMAP server
Stars: ✭ 208 (-4.59%)
Mutual labels:  composer
Ourls
url shorten service/短网址服务
Stars: ✭ 203 (-6.88%)
Mutual labels:  composer

Password Generator Library

Simple library for generating random passwords.

Build Status SensioLabsInsight

Latest Stable Version Total Downloads Latest Unstable Version License

Requirements

  • PHP >= 7.1

We only support PHP 7.3+

Installation

Install Composer

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:

$ composer require hackzilla/password-generator

Composer will add the library to your composer.json file and install it into your project's vendor/hackzilla directory.

Simple Usage

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.

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.

The segment separator will be remove from the possible characters.

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

$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.

For example the following will end up in an infinite loop.

$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.

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+

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].