passwdchars = array("!", "@", "#", "$", "%"); // push ASCII in the following ranges // 0 - 9 - twice to increase likelyhood of number vs. letter for($i=48; $i<58; $i++) { array_push($this->passwdchars, chr($i)); array_push($this->passwdchars, chr($i)); } // A - Z // for($i=65; $i<91; $i++) array_push($this->passwdchars, chr($i)); // a - z for($i=97; $i<123; $i++) array_push($this->passwdchars, chr($i)); // randomize the chars shuffle($this->passwdchars); } else { $this->passwdchars = $chararray; } $this->minlength = $min; $this->maxlength = $max; } function setLength() // private method { $this->length = rand($this->minlength, $this->maxlength); } function setMin($min) { $this->minlength = $min; } function setMax($max) { $this->maxlength = $max; } function getPassword() { $this->passwd = NULL; $this->setLength(); for($i=0; $i<$this->length; $i++) { $charnum = rand(0, count($this->passwdchars)); $this->passwd .= $this->passwdchars[$charnum]; } return $this->passwd; } // to show in browser function getHTMLPassword() { return (htmlentities($this->getPassword())); } } ?>