natanael-aguiar / secure-password-generator
A simple secure password generator
Installs: 3 318
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.66
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.4.1
- squizlabs/php_codesniffer: ^3.13
README
This PHP package allows you to generate secure passwords with configurable options, including uppercase letters, lowercase letters, numbers, and special characters.
Installation
You can install this package using Composer:
composer require natanael-aguiar/secure-password-generator
Usage
<?php require 'vendor/autoload.php'; // Loads Composer classes use SecurePasswordGenerator\SecurePasswordGenerator; $generator = new SecurePasswordGenerator(); $generator->allowLowercase(true); $generator->allowUppercase(true); $generator->allowNumbers(true); $generator->allowSpecialCharacters(true); // Generate a secure password of length 8 try { $password = $generator->generatePassword(8); echo($password); } catch (Exception $e) { echo($e); }
Documentation
SecurePasswordGenerator
(Main Class)
Methods
allowLowercase(bool $allow): void
- Enables or disables lowercase letters in the password.allowUppercase(bool $allow): void
- Enables or disables uppercase letters in the password.allowNumbers(bool $allow): void
- Enables or disables numbers in the password.allowSpecialCharacters(bool $allow): void
- Enables or disables special characters in the password.generatePassword(int $length = 12): string
- Generates a secure password with the specified length.
Contributing
See the CONTRIBUTING.md file for details on the contribution process.
Code of Conduct
This project adopts the Contributor Covenant Code of Conduct.
Running Tests, Lint, and Static Analysis
- Tests:
vendor/bin/phpunit
- Lint (PSR-12):
vendor/bin/php-cs-fixer fix --dry-run --diff --allow-risky=yes
- Static Analysis:
vendor/bin/phpstan analyse
Contribution
Contributions are welcome! Please open an issue or submit a pull request if you want to contribute.