Created
October 29, 2019 20:02
-
-
Save romaefGit/e203bdd97c4b40863843a391a3ad202e to your computer and use it in GitHub Desktop.
JavaScript - Función que genera códigos alfanuméricos
This file contains hidden or 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
| /** | |
| * Autor - Romario Augusto Estrada Flórez -romarioestrada.ff@hotmail.com | |
| * [generaCodigo genera código aleatorio alfanumérico.] | |
| * @param {[int]} longitud [Se dice de que longitud quiere el código] | |
| * @return {[string]} [el codigo generado] | |
| */ | |
| function generaCodigo(longitud) { | |
| var caracteres = "abcdefghijkmnpqrtuvwxyzABCDEFGHIJKLMNPQRTUVWXYZ2346789"; | |
| var contrasena = ""; | |
| for (i = 0; i < longitud; i++) contrasena += caracteres.charAt(Math.floor(Math.random() * caracteres.length)); | |
| return contrasena; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment