luzrain/pwgen

PWGen is a library which aims to clone the GNU pwgen functionality.

Maintainers

Details

github.com/luzrain/pwgen

Source

Installs: 4 685

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 14

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

This package is auto-updated.

Last update: 2024-10-28 21:21:47 UTC


README

PHP ^8.0 Tests Status

PWGen is a library which aims to clone the GNU pwgen functionality. The PWGen library generates passwords which are designed to be easily memorized by humans, while being as secure as possible. Human-memorable passwords are never going to be as secure as completely random passwords. In particular, passwords generated by pwgen without the secure option should not be used in places where the password could be attacked via a brute-force attack. On the other hand, completely randomly generated passwords have a tendency to be written down, and are subject to being compromised in that fashion.

Installation

$ composer require luzrain/pwgen

Usage

<?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;

License

PWGen may be distributed under the terms of the GPL License.
Copyright © 2001, 2002 by Theodore Ts'o (C version)
Copyright © 2009 by Superwayne (PHP port)