Mailinglisten-Archive |
Hi!
On Tue, 25 Jun 2002 23:20:57 +0200
Enrico Weigelt <weigelt_(at)_metux.de> wrote:
> hi leute,
>
> hat jemand von euch vielleicht ein kleines script zum
> generieren von passwoertern parat ?
function generatePassword($lenght = 8, $numbers = 2, $enable_uc = false)
{
// Erzeugt ein relativ einfach zu merkendes Passwort.
// Es wird entweder in der Form 'lukivi63' oder '36ivikul'
// zurückgegeben.
// l, 1 und 0, O wurden wegen der Verwechslungsgefahr entfernt.
$cons = array( 'b', 'c', 'd', 'f', 'g', 'h', 'j',
'k', 'm', 'n', 'p', 'q', 'r', 's',
't', 'v', 'w', 'x', 'y', 'z');
$vocal = array('a','e','i','o','u');
$num = array(2, 3, 4, 5, 6, 7, 8, 9);
if ($enable_uc) {
$cons = array_merge($cons, array('B', 'C', 'D', 'F', 'G', 'H',
'J',
'K', 'L', 'M', 'N', 'P', 'Q',
'R',
'S', 'T', 'V', 'W', 'X', 'Y',
'Z'));
$vocal = array_merge($vocal, array('A', 'E', 'O', 'U'));
}
$password='';
srand ((double)microtime()*1000000);
for ($f = 0; $f < ($lenght - $numbers); $f++) {
if ($f % 2) {
$password .= $vocal[rand(0, count($vocal) - 1)];
} else {
$password .= $cons[rand(0, count($cons) - 1)];
}
}
for ($f = 0; $f < $numbers; $f++) {
$password .= $num[rand(0, count($num) - 1)];
}
if (rand(0, 1)) {
return strrev($password);
} else {
return $password;
}
}
cu, Roland Tapken
--
Please reply to: tapken_(at)_engter.de
PGP Public Key: http://www.engter.de/~tapkenea/gnupg_roland.txt
~~~ I'm a signature-virus. Please copy me into your sig. ~~~
php::bar PHP Wiki - Listenarchive