Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/06/2004, 06:54
raulggm
 
Fecha de Ingreso: marzo-2004
Ubicación: Extremadura
Mensajes: 206
Antigüedad: 20 años, 1 mes
Puntos: 0
generar claves

Hola a tod@s,
necesito un script que me genere claves seguras. He probado con uno que he encontrado en el manual oficial de PHP:

Código PHP:
<?PHP
// ->
define('CHARPOOL',          'ABC..YZab..yz0..9'); // The characters that may appear in the password.
define('CHARPOOL_MAXINDEX',  strlen(CHARPOOL)-1); // maximum character index of a string is length-1
define('PASSWORD_LENGTH',    8); // The length of the generated password. To generate passwords with variable length use mt_rand(min_length,max_length) for this.
// <- You might want to use these values directly within the for-loop,
// but for the reason of readability they are defined as constants here.

for ($passwd=''strlen($passwd)<PASSWORD_LENGTH$passwd.=substr(CHARPOOL,CHARPOOL_MAXINDEX));

echo 
'Generated password is: '.$passwd;
?>
pero este script siempre me genera la misma clave: 99999999

Alguien puede ayudarme? Gracias.