escuelait/custom-password-generator
最新稳定版本:0.1.0
Composer 安装命令:
composer require escuelait/custom-password-generator
包简介
Custom Password Generator for PHP
README 文档
README
A lightweight, customizable password generator by Escuelait. Ideal for generating secure, random passwords with optional symbol inclusion.
Installation
Install via Composer:
composer require escuelait/custom-password-generator
Quick Usage
use Escuelait\CustomPasswordGenerator\PasswordGenerator; $generator = new PasswordGenerator(); // Generate a 12-character password with 2 symbols (default settings) $password = $generator->generate(); echo $password; // Example: @k1Zq9&Lm08A
Configuration
You can customize both the total password length and the number of symbols:
$password = (new PasswordGenerator()) ->length(16) // Total length of the password ->symbols(4) // Number of symbols to include ->generate(); echo $password; // Example: %aB3#XgF1$Ld9&kM
⚠️ If the number of symbols exceeds the total password length, an
InvalidArgumentExceptionwill be thrown.
How It Works
-
Character sets used:
- Letters:
a-z,A-Z - Numbers:
0-9 - Symbols:
!@#$%&*()_+-=[]{}|;:,.<>?
- Letters:
-
Defaults:
- Length:
12 - Symbols:
2
- Length:
-
Fluent methods:
length(int $length)— Set total password length.symbols(int $symbols)— Set number of symbols.
Example
use Escuelait\CustomPasswordGenerator\PasswordGenerator; $password = (new PasswordGenerator()) ->length(20) ->symbols(5) ->generate(); echo $password;
❗ Exceptions
If the number of requested symbols exceeds the total length:
InvalidArgumentException: The number of symbols cannot exceed the total password length
Future Improvements
- Unit tests
- Option to exclude ambiguous characters
- CLI version
License
This package is open-sourced under the MIT license.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-13