Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?PHP
- // selection of possible character
- $letters = array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");
- $numbers = array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9");
- $special = array("!", "&", "=", "?");
- $length = 8;
- // Generate secure passwords
- $password = "";
- for($i=0; strlen($password)<$length; $i++){
- $random = mt_rand(1,100);
- if($random < 50)
- {$password.=$letters[mt_rand(0, count($letters)-1)];}
- elseif($random > 60)
- {$password.=$numbers[mt_rand(0, count($numbers)-1)];}
- else
- {$password.=$special[mt_rand(0, count($special)-1)];}
- }
- // output
- echo "Password: $password";
- ?>
Add Comment
Please, Sign In to add comment