1
0
mirror of https://github.com/postfixadmin/postfixadmin.git synced 2025-07-31 10:04:20 +03:00

update generate_password() to allow length to be specified; update test

This commit is contained in:
David Goodwin
2018-05-02 21:10:06 +01:00
parent 7388a7ca62
commit 7282928e6d
2 changed files with 20 additions and 8 deletions

View File

@ -832,14 +832,13 @@ function encode_header($string, $default_charset = "utf-8") {
//
// generate_password
// Action: Generates a random password
// Call: generate_password ()
//
function generate_password() {
// length of the generated password
$length = 12;
/**
* Generate a random password of $length characters.
* @param int $length (optional, default: 12)
* @return string
*
*/
function generate_password($length = 12) {
// define possible characters
$possible = "2345678923456789abcdefghijkmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ"; # skip 0 and 1 to avoid confusion with O and l