Generador de contraseñas aleatorias

Como una alternativa simple y rápida de usar al Generador de contraseñas aleatorias para Excel, hice esta adaptación Javascript del código de la función de generación aleatoria de contraseñas… Podés ver el código fuente más abajo…


Mayúsculas Minúsculas Números

Contraseña Aleatoria

GNU GPL v3El código está liberado bajo la licencia GNU GPL v3
En caso de que quieras ver el código de la función sin tener que buscar en el código fuente de la página:

Random Password Generator by NeoEGM

Copyright (C) 2009 Ezequiel Gastón Miravalles

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <>.

Software: Random Password Generator by NeoEGM
Author: Ezequiel Gastón Miravalles
License: GNU GPL v3 (read above)

function RandomPassword(Length, Upper, Numbers, Lower)
	Upper = typeof(Upper) != 'undefined' ? Upper : true;
	Numbers = typeof(Numbers) != 'undefined' ? Numbers : true;
	Lower = typeof(Lower) != 'undefined' ? Lower : true;
    if (!Upper && !Lower && !Numbers)
		return "";

    var Ret = "";
    var Num;
    var Repeat;

    Chars = 26 * 2 + 10;	//26 (a-z) + 26 (A-Z) + 10 (0-9)
	//a-z = 97-122
	//A-Z = 65-90
	//0-9 = 48-57

    for (i = 1; i <= Length; i++)
        Repeat = false;

        Num = Math.floor(Math.random()*Chars);

        if (Num < 26)
            if (Lower)
                Ret = Ret + String.fromCharCode(Num + 97);
                Repeat = true;
        else if (Num < 52)
            if (Upper)
                Ret = Ret + String.fromCharCode(Num - 26 + 65);
                Repeat = true;
        else if (Num < 62)
            if (Numbers)
                Ret = Ret + String.fromCharCode(Num - 52 + 48);
                Repeat = true;

        if (Repeat)

    return Ret;

Support appreciated!

All the content offered in this website is, except noted otherwise, of free nature. This means you can share it wherever you want if you do it freely and stating its source.

If it was useful for you and you’d like to contribute, you can make a donation or, at least, visit one of our advertisers of your choice; they are all around the site.

Incoming search terms for the article:

1 Responses to “Generador de contraseñas aleatorias”

Leave a Reply