Просмотр файла genpass.html

Размер файла: 5.59Kb
<html>
<head>
<META HTTP-EQUIV=Content-Type Content=text/html; Charset=UTF-8>
<script language="javascript" src="js/title.js"></script> 
<script language="javascript" src="js/style.js"></script> 
</head>
<body>

<div class=quote>
<script language="javascript" src="js/logo.js"></script>
</div>

<script language="javascript" src="js/rek_head.js"></script> 


<div class='bmenu'>Генератор паролей</div>
<div class='quote'> 

<script language="JavaScript1.2">
with (document) {
	writeln('</head><form name=myform>' +
	'<table><tr><td><b>Какие символы использовать в пароле?</b></td></tr>' +
	'<tr><td><input OnClick=OnCheck(0) class=chk name=upper type=checkbox value=0>&nbsp;Заглавные буквы [A]</td></tr>' +
	'<tr><td><input OnClick=OnCheck(0) class=chk name=lower type=checkbox value=1>&nbsp;Маленькие буквы [a]</td></tr>' +
	'<tr><td><input OnClick=OnCheck(0) class=chk name=speci type=checkbox value=0>&nbsp;Спецсимволы [!]</td></tr>' +
	'<tr><td><input OnClick=OnCheck(0) class=chk name=digit type=checkbox value=2>&nbsp;Цифры [0]</td></tr>' +
	'<tr><td>&nbsp;По шаблону&nbsp;' +
	'<input OnClick=OnCheck(1) name=gettempl size=10 maxlength=20 type=text value=""></td></tr>' +
	'<tr><td>Длина пароля:&nbsp;' +
	'<select name=numbers>');
	for (j = 4; j <= 19; j++) { writeln('<option value=' + j + ((j==10)?' selected':'')+'>' + j + '</option>'); }
	writeln('</select></td></tr>' +
	'<tr><td style="padding-top:10"><input type=button value=Сгенерировать onClick=generate()><br><br>&nbsp;<B>Ваш пароль:</B><BR>' +
	'</td></tr><table>');
	for(j=0;j<10;j++)
	{
		ne = 'gb'+j;
		writeln('<tr><td><input name='+ne+' size=25 maxlength=30 type=text value=""></td></tr>');
	}
	writeln('</table></form>');
}
// массивы символов
upp = new Array('','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z');
low = new Array('','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z');
dig = new Array('','0','1','2','3','4','5','6','7','8','9');
spe = new Array('','~','@','#','$','%','&','*','+','=','!');
// ------------------------------------------------------------------------------
function ccl(a){window.clipboardData.setData('text', eval('document.myform.gb'+a+'.value'));}
// -----------------------------------------f------------------------------------
function OnCheck(b)
{
    if(b)
    {
        document.myform.upper.checked=0;
        document.myform.lower.checked=0;
        document.myform.digit.checked=0;
        document.myform.speci.checked=0;
        }else
        document.myform.gettempl.value = '';
}
// --------------------------------------------------------------------------------------------------------------------------------------------------------------
function rnd(x,y,z) {
	var num;
	do {
		num = parseInt(Math.random()*z);
		if (num >= x && num <= y) break;
	} while (true);
return(num);
}
// --------------------------------------------------------------------------------------------------------------------------------------------------------------
function genArray() {
	var pwd = '';
	var res, s;
	var k = 0;
	var n = document.myform.numbers.value;
    var tn = document.myform.gettempl.value;
    if (myform.gettempl.value.length>0)
        n = tn.length;
	var pass = new Array();
	var w = rnd(30,80,100);
    if (tn.length>0)
    {
        for(var r = 0; r<tn.length; r++)
        {
            i = tn.substr(r,1);
            switch(i)
            {
                case 'A':
                    res = rnd(1,26,100);
                    pwd += upp[res];
                    break;
                case 'a':
                    res = rnd(1,26,100);
                    pwd += low[res];
                    break;
                case '!':
                    res = rnd(1,10,100);
                    pwd += spe[res];
                    break;
                case '0':
                    res = rnd(1,10,100);
                    pwd += dig[res];
                    break;
                default:
                    pwd += i;
            }
        }
    }else
    {
	for (var r = 0; r < w; r++) {
		if (myform.upper.checked) { res = rnd(1,26,100); pass[k] = upp[res]; k++; }
		if (myform.lower.checked) { res = rnd(1,26,100); pass[k] = low[res]; k++; }
		if (myform.digit.checked) { res = rnd(1,10,100); pass[k] = dig[res]; k++; }
		if (myform.speci.checked) { res = rnd(1,10,100); pass[k] = spe[res]; k++; }
	}
	for (var i = 0; i < n; i++) {
		s = rnd(1,k-1,100);
		pwd+= pass[s];
	}
    }
	return pwd;
}
// --------------------------------------------------------------------------------------------------------------------------------------------------------------
function generate() {
	if ((myform.upper.checked || myform.lower.checked || myform.speci.checked || myform.digit.checked) ||
        (myform.gettempl.value.length>0))
	{ for(i=0;i<10;i++){eval('document.myform.gb'+i+'.value=genArray()');} }
	else { alert('Выберите символы, из которых будет состоять пароль!'); myform.upper.checked = true; }
}
</script>

<br><br><a href="index.html">На главную</a>
</div>


</div>

<script language="javascript" src="js/rek_foot.js"></script> 

<div class='end'> 
<script language="javascript" src="js/yournick.js"></script> 
</div>
<hr>


<center><script language="javascript" src="js/ban.js"></script> </center>

</body>
</html>