newdbpassword
newdbpassword
SYNOPSIS
newdbpassword($len=10)
DESCRIPTION
newdbpassword
returns a random secure password for a DB connector.
CODE
- require_once 'strrand.php';
- function newdbpassword($len=10) {
- $charset = array('ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz', '0123456789', '~!@#$%^&*()_-+={}[]/<>,.;?:|');
- $pwd = strrand($charset[0], 2) . strrand($charset[1], 2) . strrand($charset[2], 2) . strrand($charset[3], 2);
- $len = max($len, 10) - strlen($pwd);
- while ($len-- > 0) {
- $pwd .= strrand($charset[rand(0, count($charset) - 1)], 1);
- }
- return str_shuffle($pwd);
- }
newdbpassword
returns a minimum of 10 random characters with at least 2 uppercase letters, 2 lowercase letters, 2 digits and 2 special characters.
Comments