Title: Generate a Random Password with PHP
Contributor: Randall Goguen (aka Ranman)
Last Update: Tuesday July 11 16:43 EDT 2000
# Note: 1. You can add more charactors, numbers or lower case charactors
# to '$possible_charactors' is you wish.
# 2. You can change the string length, for example,
# echo 'Random_Password(16);' for 16 charactors.
<?
function Random_Password($length) {
srand(date("s"));
$possible_charactors = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$string = "";
while(strlen($string)<$length) {
$string .= substr($possible_charactors,(rand()%(strlen($possible_charactors))),1);
}
return($string);
}
echo Random_Password(8);
?>
Anyone who wishes to make additions or changes to this
PHP Tip email them to webmaster@linuxguruz.org
This document is Copyright (c) 1999, 2000 by LinuxGuruz