note 58411 added to function.str-shuffle
| From: | nmoyroud at teledetection dot fr | Date: | Thu, 03 Nov 2005 12:38:28 +0000 |
| Subject: | note 58411 added to function.str-shuffle | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-98022@lists.php.net to get a copy of this message | ||
Just another update to password builder function. With this version, you can choose the number of
alphanumeric characters to add and the number of non-alphanumeric characters. You obtain a more
secure password. You can add another characters to the non-alphanumeric list if you need.
If you want a password with 8 alphanumeric and 3 non-alphanumeric characters in a random order, just
call :
random_passwd(8,3);
function generatePasswd($numAlpha=6,$numNonAlpha=2) {
$pwd = '';
$listAlpha = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
$listNonAlpha = ',;:!?.$/*-+&@_+;./*&?$-!,';
$start = mt_rand(1, (strlen($listAlpha)-$numAlpha));
$string = str_shuffle($listAlpha);
$pwd .= substr($string,$start,$numAlpha);
$start = mt_rand(1, (strlen($listNonAlpha)-$numNonAlpha));
$string = str_shuffle($listNonAlpha);
$pwd .= substr($string,$start,$numNonAlpha);
return str_shuffle($pwd);
}
----
Manual Page -- http://www.php.net/manual/en/function.str-shuffle.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+58411
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+58411&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+58411&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+58411&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+58411&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+58411&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+58411&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+58411&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+58411&report=yes
Search -- http://master.php.net/manage/user-notes.php