27
Oct
Comparto esta funcion para generar claves aleatorias. Es facil de usar y de entender.
-
-
<?php
-
-
function generatePassword( $length=9, $strength=4 ) {
-
$vowels = ‘aeiou’;
-
$consonants = ‘bcdfghjklmnpqrstvwxyz’;
-
if ($strength & 1) {
-
$consonants .= ‘BCDFGHJKLMNPQRSTVWXYZ’;
-
}
-
if ($strength & 2) {
-
$vowels .= "AEIOU";
-
}
-
if ($strength & 4) {
-
$consonants .= ‘23456789′;
-
}
-
if ($strength & 8) {
-
$consonants .= ‘@#$%’;
-
}
-
-
$password = ”;
-
for ($i = 0; $i < $length; $i++) {
-
if ($alt == 1) {
-
$alt = 0;
-
} else {
-
$alt = 1;
-
}
-
}
-
return $password;
-
}
-
-
?>
-



October 27th, 2008 at 5:43 pm
No salio la fuente.
http://www.webtoolkit.info/php-random-password-generator.html
October 27th, 2008 at 6:12 pm
Yo usaria mt_rand() en lugar de rand(). Muy buen aporte, gracias por compartir.
Saludos
October 27th, 2008 at 7:35 pm
Interesante. Gracias!
October 29th, 2008 at 2:15 pm
@ramon: tenes toda la razon, no la conocia
http://ar2.php.net/mt_rand