28
newpassword
newpassword
SYNOPSIS
newpassword($len=8)
DESCRIPTION
newpassword
returns a random password of $len
characters.
CODE
- require_once 'strrand.php';
- function newpassword($len=8) {
- $charset = array('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz', '0123456789');
- $pwd = strrand($charset[0], 1) . strrand($charset[1], 1) . strrand($charset[2], 1);
- $len = max($len, 4) - strlen($pwd);
- while ($len-- > 0) {
- $pwd .= strrand($charset[rand(0, count($charset) - 1)], 1);
- }
- return str_shuffle($pwd);
- }
newpassword
returns 6 random letters or digits.
Comments