luzrain/pwgen

PWGen 是一个旨在模仿 GNU pwgen 功能的库。

v1.0.0 2022-11-23 05:36 UTC

This package is auto-updated.

Last update: 2024-08-28 20:56:22 UTC


README

PHP ^8.0 Tests Status

PWGen 是一个旨在模仿 GNU pwgen 功能的库。PWGen 库生成的密码旨在易于人类记忆,同时尽可能安全。人类记忆的密码永远不会像完全随机的密码那样安全。特别是,没有使用 secure 选项生成的 pwgen 密码不应该用于可能遭受暴力攻击的地方。另一方面,完全随机生成的密码容易被人记录下来,因此也容易受到这种方式的影响。

安装

$ composer require luzrain/pwgen

用法

<?php

use PWGen\PWGen;

/**
 * Available options in the PWGen constructor. All of them are optional.
 *
 * length:      Length of the generated password. Default: 8
 * capitalize:  Include at least one capital letter in the password.
 * numerals:    Include at least one number in the password.
 * symbols:     Include at least one special symbol in the password.
 * secure:      Generate completely random passwords.
 * ambiguous:   Don't include ambiguous characters in the password.
 * noVowels:    Do not use any vowels to avoid accidental nasty words.
 * removeChars: Remove characters from the set of characters to generate passwords.
 */
$pwgen = new PWGen(length: 12, symbols: true);
$password = (string) $pwgen;

/**
 * Regenerate password with given options
 */
$pwgen->generate();
$password = (string) $pwgen;

许可

PWGen 可以根据 GPL 许可证的条款进行分发。
版权所有 © 2001, 2002 Theodore Ts'o(C 版本)
版权所有 © 2009 Superwayne(PHP 版本)