Random password generator

Avatar-eric-london
Created by Eric.London on 2008-04-14
Tags:
New Comment
 
Here is a script I wrote to generate passwords...

<?php
function passwordCreate($length = 8) {
  if ($length>62 || $length<1) $length = 8;
  $chars = array();
  for ($i=0; $i<$length; $i++) {
    do {
      $r = rand(48, 122);
    }
    while (($r>57 && $r<65) || ($r>90 && $r<97) || in_array(chr($r),$chars));
      $chars[] = chr($r);
  }    
  return implode('', $chars);
}
?>

Comments

 
  • Thanks Eric
    Created by Anonymous on 2011-06-01
    Thanks Works fine