note 57565 added to function.mt-rand
| From: | phil | Date: | Fri, 07 Oct 2005 13:13:06 +0000 |
| Subject: | note 57565 added to function.mt-rand | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-96555@lists.php.net to get a copy of this message | ||
Quit bothering yourselves.
All it takes to create a secure random-generated password is those three lines:
<?php
$pass = "";
// Generate a 8 char password
for ($i=0; $i<8; $i++)
$pass .= chr(mt_rand(35, 126));
?>
Note:
In this example, the character's ASCII values range from 35 to 126.
For character's ASCII codes please check:
http://www.keller.com/html-quickref/latin1.html
----
Manual Page -- http://www.php.net/manual/en/function.mt-rand.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+57565
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+57565&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+57565&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+57565&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+57565&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+57565&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+57565&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+57565&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+57565&report=yes
Search -- http://master.php.net/manage/user-notes.php