Einfach ein kleines Beispiel für ein relativ sicheres Passwort:
PHP-Code:
<?php
function pw_ok($passw){
/*
** Function Checks consistency of a password
** The password must consist of at least one digit,
** lower- und uppercase letter and a special sign
**
** Parameter: String: $passw
**
** Return value: Boolean
*/
return preg_match('/[[:digit:]]/', $passw) && // Ziffern
preg_match('/[[:lower:]]/', $passw) && // Kleinbuchstaben
preg_match('/[[:upper:]]/', $passw) && // Grossbuchstaben
preg_match('/[[:punct:]]/', $passw); // Sonderzeichen
}
function gen_passwd($anz = 8){
/*
** Function: Generate password
**
** Parameter:
** $anz Int: length of password default: 8
**
** Return value: String: Generated password
*/
$z1 = range(33, 47); // Kein O (Buchstabe) und kein 0 (Null)
$z2 = range(49, 78);
$z3 = range(80, 126);
$zeichen = array_merge($z1, $z2, $z3);
do{
$passw = '';
shuffle($zeichen);
for($i = 0;$i < $anz;$i ++){
$passw .= chr($zeichen[$i]);
}
} while(!(pw_ok($passw)));
return $passw;
}
?>