Last active
December 23, 2015 10:19
-
-
Save ivolivares/6621176 to your computer and use it in GitHub Desktop.
Una cadena de texto aleatoria, perfecto para "contraseñas seguras" (sin entropía obviamente).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Random String (); | |
* Developed by: @ivolivares | |
* | |
* Uso: randomString(20); | |
* Donde: 20 = Cantidad de caracteres o el largo total del texto a generar. | |
* | |
*/ | |
function randomString($charactersLength = 30) { | |
$characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
$randomResult = ""; | |
$length = strlen($characters); | |
for ($i = 0; $i < $charactersLength; $i++) { | |
$randomResult .= $characters[rand(0, $length)]; | |
} | |
return $randomResult; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment