Skip to content

Commit

Permalink
Merge pull request #2145 from pedrofaria18/gerador-senha
Browse files Browse the repository at this point in the history
Adicionando um app para geração de senhas
  • Loading branch information
fineanmol committed Oct 3, 2022
2 parents 49388d8 + ef693fd commit 5c1cee2
Showing 1 changed file with 130 additions and 0 deletions.
130 changes: 130 additions & 0 deletions frontend projects/GeradorSenha.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt-br" lang="pt-br">
<head>
<title>Gerador de senhas</title>

<script type="text/javascript">
function dec2hex(numero) {
var base = 16;
var digito = new Array();
var i = 0;

while (numero != 0) {
i++;
digito[i] = numero % base;
numero = Math.floor(numero / base);
}
value = "";
while (i >= 1) {
switch (digito[i]) {
case 10: {
value += "A";
break;
}
case 11: {
value += "B";
break;
}
case 12: {
value += "C";
break;
}
case 13: {
value += "D";
break;
}
case 14: {
value += "E";
break;
}
case 15: {
value += "F";
break;
}
default: {
value += digito[i];
break;
}
}
i--;
}
return value;
}

function GerarSenha() {
document.forms[0].senha.value = "";
tamanho = document.forms[0].digitos.value;

if (tamanho < 1 || isNaN(tamanho)) {
alert("Escolha um valor num�rico v�lido para esse campo");
document.forms[0].digitos.focus();
document.forms[0].digitos.select();
return;
}

document.forms[0].senha.style.width = tamanho * 9 + "px";

min = 32;
max = 126;

for (i = 1; i <= tamanho; i++) {
caracter = min + Math.floor(Math.random() * (max - min));
caracter = "%" + dec2hex(caracter);
caracter = unescape(caracter);
document.forms[0].senha.value += caracter;
document.getElementById("aguarde").innerHTML = "aguarde...";
}
document.getElementById("aguarde").innerHTML = "";
}
</script>

<style type="text/css">
* {
font: 11px Verdana;
}
.campo1 {
width: 180px;
}
.campo2 {
width: 40px;
}
.campo1,
.campo2 {
border: solid 1px #ccc;
}
.botao {
border: solid 1px #bbb;
background-color: #eee;
cursor: pointer;
}
#aguarde {
font-style: italic;
}
</style>
</head>

<body>
<form action="#" onsubmit="GerarSenha(); return false">
Senha:
<input
type="text"
name="senha"
size="30"
class="campo1"
readonly="readonly"
/>&nbsp;&nbsp;
<input type="submit" value="Gerar senha" class="botao" /><br /><br />
Dígitos:
<input
type="text"
value="20"
name="digitos"
size="3"
class="campo2"
maxlength="2"
/>
</form>
<br />
<div id="aguarde"></div>
</body>
</html>

0 comments on commit 5c1cee2

Please sign in to comment.