tbetool/php-password-generator

该软件包最新版本(v1.4)没有提供许可证信息。

PHP 随机和安全的密码生成类

v1.4 2017-11-03 12:47 UTC

This package is auto-updated.

Last update: 2024-09-17 00:14:24 UTC


README

用于随机和安全生成密码的 PHP 类

安装

composer require tbetool/php-password-generator

使用方法

创建对象

use TBETool\PasswordGenerator;

$passwordGenerator = new PasswordGenerator();

您可以选择在构造函数中传递以下参数

use TBETool\PasswordGenerator;

$passwordGenerator = new PasswordGenerator($length, $count, $characters);

参数详情

$length (int) : Length of the password to generate, Default: 8
$count (int) : No of passwords to generate, Default: 1
$characters (string): Characters to use while password generation

支持的字符

  1. 小写字母
  2. 大写字母
  3. 数字
  4. 特殊符号

带参数的示例

use TBETool\PasswordGenerator;

$passwordGenerator = new PasswordGenerator(16, 5, 'lower_case,numbers,special_symbols');

在创建对象后设置参数

在对象创建期间设置的参数将被覆盖。

# Set lenght of password to 16
# params: (int) length
$passwordGenerator->setLength(16);

# Set number of passwords to generate
# params: (int) count
$passwordGenerator->setCount(5);

# Set characters to use in password
# params: (string) characters
$passwordGenerator->setCharacters('lower_case,numbers');

生成密码

这将返回所有生成的密码中的一个密码

@return string of password
$password = $passwordGenerator->generate();

获取所有生成的密码

@return array of passwords
$passwords = $passwordGenerator->getPasswords();

从生成的密码中获取新密码

@return string of new password
$password = $passwordGenerator->getPassword();

获取最后访问的密码

@return string of last password retrieved
$password = $passwordGenerator->getLastPassword();

开发者

Anuj Sharma (https://anujsh.in)

软件包

TBE (http://thebornengineer.com)