承接 wee/randompassword 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

wee/randompassword

最新稳定版本:3.0.1

Composer 安装命令:

composer require wee/randompassword

包简介

Random password generator

README 文档

README

Requires PHP 8.0 or later

Description

string wee_randomPassword( [ int length [, string type [, mixed charsets ]]] )

The function was written to create strong passwords with a decent level of control over the final output. You can specify length and type of the password. It is also possible to create a custom password type.

To achieve control over the output character sets are used. From each set an equal amount of characters is selected. Also each character in a set has to be used, before it can be selected again. This ensures that all character types are used and repeating characters are kept to a minimum.

The function returns a UTF-8 encoded string. Characters for a custom type must be UTF-8 encoded.

Table: function parameters

parameterdescription
lengthpassword length (default: 8)
typepassword type (default: alphanumeric)
charsetscustom character sets (only for type "custom")

Table: password types

typecharacter sets
alphanumeric (default)ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789
reduced (=alphanumeric without 0oO9g1lI)ABCDEFGHJKLMNPQRSTUVWXYZ abcdefghijkmnpqrstuvwxyz 2345678
alphabeticalABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
asciiABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz 0123456789 `~!@#$%^&*()-_=+\⎮[]{};:'",.<>/?``
latin1ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝ àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþÿ 0123456789 `~!@#$%^&*()-_=+\⎮[]{};:'",.<>/?``
hexadecimal0123456789 abcdef
numeric0123456789
customuser defined (UTF-8 encoded)

Although this function should create a strong password, there is no 100% guarantee. There is still a small chance that this function creates a password like: ABCabc123. To test the strength of a generated password, you can use for example cracklib.

Examples

require_once 'randompassword.php';

// Default behaviour (no parameters), e.g. 3pHJXd4l
$password1 = wee_randomPassword();

// Password with length 8 and type ascii, e.g. 7w$6aDR~
$password2 = wee_randomPassword(8, 'ascii');

// Password with length 6 and only lowercase letters, e.g. fkslhu
$password4 = wee_randomPassword(6, 'custom', 'abcdefghijklmnopqrstuvwxyz');

// Password with length 16 and only uppercase letters + numbers, e.g. 71H5N92GJK0I6E3A
$password5 = wee_randomPassword(16, 'custom', ['ABCDEFGHIJKLMNOPQRSTUVWXYZ', '0123456789']);

License

The package is released under the MIT License

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-24