Topic: random pass
Now actual 1.2 code
//
// Generate a random password of length $len
//
function random_pass($len)
{
$chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
$password = '';
for ($i = 0; $i < $len; ++$i)
$password .= substr($chars, (mt_rand() % strlen($chars)), 1);
return $password;
}
Maybe better:
function random_pass () {
$length ="8"; // the length of the password required
$possible = '23456789abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ';
$str ="";
while (strlen($str) < $length) {
$str.=substr($possible, (rand() % strlen($possible)),1);
}
return($str);
}
// Adapted from code by the following author:
//
// Author: mr.shifter@hosted.uklinux.net
// http://www.hosted.uklinux.net/php/freescripts/index.php
//
// All Rights Reserved Free to use don't abuse
// PLEASE NOTE:The numbers 0 and 1 (zero and one) and the letters
// l and o, ('el' and 'oh' in lowercase) and the letters I and O
// ('eye' and 'oh' in uppercase) have been removed from the random
// generator, so as not to cause confusion when writing them down.