Mailinglisten-Archive |
Hallo Till,
> ich brauche für eine Anmeldungsseite einer Auktion,
> an der in gerade arbeite, eine Funktion,
> die mir ein Passwort aus Zahlen und Buchstaben generiert.
>
> mt_rand() kann bloß Zufallszahlen, oder???
Probiers mal hiermit ;)
<?
srand((double)microtime()*1000000);
$characters = "a,b,c,d,e,f,1,2,3,4,5,A,B,C,D,E,F";
// symbols where are allowed in the password
$characters_length = (strlen($characters)-1)/2; $token =
explode(",",$characters);
$pass_length=8; // length of the password
for($i=0;$i<$pass_length;$i++) {
$rand = rand(0,$characters_length);
$password.= $token[$rand];
}
echo "$password";
?>
<?
srand((double)microtime()*1000000);
$token = md5(uniqid(rand()));
$password = substr($token, 0, 3);
$password .= substr($token, 5, 2);
$password .= substr($token, -3);
echo "$password";
?>
Grüsse aus Frankfurt,
Marcel "Mazen" Beerta
http://www.mazenphp.de | http://www.beerta.de | http://marcel.beerta.de
marcel_(at)_beerta.de
php::bar PHP Wiki - Listenarchive