Skip to content

Instantly share code, notes, and snippets.

@ErikRamses
Last active December 19, 2015 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ErikRamses/5927519 to your computer and use it in GitHub Desktop.
Save ErikRamses/5927519 to your computer and use it in GitHub Desktop.
Página html del servidor apache
<html>
<head>
<title>Login</title>
</head>
<body>
<h1>Ingreso al Sistema</h1>
<p>Ingrese los siguientes datos:
</p>
<form name="datos" id="datos">
<table>
<tr>
<th><code>Usuario</code></th>
<td><input type="text" size="10" name="usuario" id="usuario" value=""></td>
</tr>
<tr>
<th>Valor del modulo</th>
<td><input type="text" size="10" name="modulo" id="modulo" value=""></td>
</tr>
<tr>
<th>Valor de llave privada</th>
<td><input type="text" size="10" name="llave" id="llave" value=""></td>
</tr>
</table>
</form>
<h3>Estado del autentificador:</h3>
<div id="res"></div>
<script language="javascript">
function potmod(x, pot, mod)
{
if(n==1)
{
return x;
}
else if(pot%2 ==0)
{
return Math.pow(potmod(x, pot/2, mod), 2)%mod;
}
else
{
return (x*potmod(x, pot-1, mod))%mod;
}
}
function evalua(form)
{
$.post( "http://127.0.0.1/usr/lib/cgi-bin/test-script.py", {},
function(datos)
y= cambio(parseInt(datos));
n= parseInt(document.forms[form].elements["modulo"].value)
d= parseInt(document.forms[form].elements["llave"].value)
usuario= String(document.forms[form].elements["usuario"].value)
num = potmod(y, d, n).toPrecision(100);
num.substring(0, num.indexOf("."));
$post("http://127.0.0.1/usr/lib/cgi-bin/test_script.py"), {"x":num, "usuario":usuario},
function(datos)
{
if(datos.indexOf("True")!=-1)
{
document.getElementById("res").innerHTML=("<h2> El usuario:'"+usuario+"' esta autenticado.<h2>");
}
else if(datos.indexOf("False")!=-1)
{
document.getElementById("res").innerHTML=("<h2> El usuario:'"+usuario+"' no esta autenticado.<h2>");
}
else
{
document.getElementById("res").innerHTML=("<h2> Vuelva a llenar el formulario <h2>");
}
}
);
}
</script>
<p>
<button onClick="evalua()">Evaluar</button>
</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment