PHPBuilder - mkpasswd

# mkpasswd

by: Benjamin Smith
|
November 13, 2001

Version: 1.02

Type: Function

Category: Other

Description: This function seeks to mimic the mkpasswd script that comes with the 'expect' progrom found at http://expect.nist.gov/ . A random password is generated using the the parameters specified. You can specify the length of the password, the minimum number of alphabets, numbers and symbols it can have, exclude character types, specify allowable symbols, letter case.

```list(\$usec,\$sec)=explode(" ",microtime());
mt_srand(\$sec * \$usec);

{
\$possible='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefhijklmnopqrstuvwxyz098765432\$              \$return='';
for (\$i=0; \$i<\$length; \$i++)
{
\$key=mt_rand(0, strlen(\$possible)-1);
\$return.=\$possible[\$key];
}
return \$return;
}```

Comment and Contribute

## Your comment has been submitted and is pending approval.

Author:
Benjamin Smith

Comment:

Comment:

(Maximum characters: 1200). You have characters left.