Generate Random Password

I was looking for a simple php random password generator. I ended up modifying Jon Haworth’s password generator to come up with this.

function generatepass($length = 8) {
  $password = "";
  $possible = "0123456789bcdfghjkmnpqrstvwxyzBCDFGHJKMNPQRSTVWXYZ";
  for($i=0;$i <= $length;$i++) {
    $password .= $possible[mt_rand(0, strlen($possible)-1)];
  }
  return $password;
}

We remove all vowels to avoid words (which will be random and might be bizarre or offensive) and the letter l to avoid confusion. I also added capital letters (I think people are used to case sensitive passwords, we just cut and paste them anyway.)