juststeveking/password-generator
Composer 安装命令:
composer require juststeveking/password-generator
包简介
Generate random, memorable passwords easily.
README 文档
README
Disclaimer. This is not intended for use in a production environment to create your passwords. My use case for this is to actually generate one off use codes such as One Time Pass Codes. This is not the most secure as the list of words is quite small, and will leave you open to a potential dictionary attack.
Installation
You can install the package via composer:
composer require juststeveking/password-generator
If you are using Laravel, you can publish the config file with:
php artisan vendor:publish --tag="password-generator-config"
Set up - Laravel
To set this package up, you can replace the words within the config file with those of your own choosing. Then you are ready to go.
Usage
Using the Facade in Laravel
Call the facade directly to resolve the Password Generator from the container and call the static methods.
use JustSteveKing\PasswordGenerator\Facades\Generator; // Generate a standard password $password = Generator::generate(); // example 'strong-car-fast-snail' // Generate a "secure" password $password = Generator::generateSecure(); // example 'str0ng-c4r-f4st-sn41l'
Without the Facade in Laravel
Inject the contract into the constructor, and call either "generate" or "generateSecure" depending on your use case.
use JustSteveKing\PasswordGenerator\Contracts\GeneratorContract; use Illuminate\Http\JsonResponse; class GeneratePasswordController { public function __construct( private readonly GeneratorContract $generator, ) {} public function __invoke(): JsonResponse { return new JsonResponse( data: [ 'password' => $this->generator->generate(), // or generateSecure() for "secure" passwords. ], ); } }
Using outside of Laravel
If you have a DI container all you will need to do is resolve the class using the instance. Be mindful that you will need to set up your own container instructions and load in your own words list.
// Once you have added this to your container, and injected $password = $this->generator->generate(); // Or like the Laravel implementation, generate a secure password $password = $this->generator->generateSecure();
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
License
The MIT License (MIT). Please see License File for more information.
juststeveking/password-generator 适用场景与选型建议
juststeveking/password-generator 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 46 次下载、GitHub Stars 达 23, 最近一次更新时间为 2022 年 11 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 juststeveking/password-generator 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 juststeveking/password-generator 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 46
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 23
- 点击次数: 16
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-11-16