// Generates a random password with given length public static function getNewPassword($length = 12) { $chars = array("abcdefghijklmnpqrstuvwxyzABCDEFGHIJKLMNPQRSTUVWXYZ", "123456789", "@!#$%&/()=-_?+*.,:;"); $count = array((strlen($chars[0]) - 1), (strlen($chars[1]) - 1), (strlen($chars[2]) - 1)); if ($length > 64) { $length = 64; } $pass = ""; for ($i = 0; $i <= $length; $i++) { $type = mt_rand(0, 2); $pass .= substr($chars[$type], mt_rand(0, $count[$type]), 1); } return $pass; }