Password generator function

/**
* @param int $min_length
* @param null $characters
* @return string
*/
function _password_generator($min_length = 8, $characters = NULL) {
  $password = '';
  if (is_null($characters)) {
    $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()';
  }
  for ($i=0;$i<$min_length;$i++) {
    $pos = rand(0,(strlen($characters)-1));
    $password .= $characters[$pos];
  }
  return $password;
}

Add new comment