定制 juststeveking/password-generator 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

juststeveking/password-generator

最新稳定版本:1.0.0

Composer 安装命令:

composer require juststeveking/password-generator

包简介

Generate random, memorable passwords easily.

README 文档

README

Latest Version on Packagist Test Suite Total Downloads

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.

统计信息

  • 总下载量: 46
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 23
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 23
  • Watchers: 3
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-16

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固