rsa_workbench/gcd.php

50 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2012-02-14 18:45:18 +00:00
<html>
<body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f">
<h1> The Numbers </h1>
<?php
2012-02-17 13:18:51 +00:00
$e = $_POST['e'];
$d = $_POST['d'];
$p = $_POST['p'];
$n = $_POST['n'];
$q = $_POST['q'];
$phi = $_POST['phi'];
$mprivate = $_POST['mprivate'];
2012-02-14 18:45:18 +00:00
//echo " gcd($e,$phi) == ";
$big_num = `echo "a=$e; b=$phi; while(b) {a=a%b; r=b; b=a; a=r;}; a;" | bc `;
printf(" <h2> gcd($e,$phi) == %s </h2>",$big_num);
if ($big_num == 1) {
printf("<h2>So these numbers are co-prime</h2><h2> the value for e is therefore acceptable </h2>\n");
printf("<form enctype=\"multipart/form-data\" method=\"post\" action=\"generate_key.php#D\">");
}
else {
printf("<h1>e is not coprime to M</h1><h1> go back and try another value for e</h1>\n");
printf("<form enctype=\"multipart/form-data\" method=\"post\" action=\"generate_key.php#GCD\">");
}
?>
<input type="hidden" name=p value=<?php echo $p ?>>
<input type="hidden" name=q value=<?php echo $q ?>>
<input type="hidden" name=phi value=<?php echo $phi ?>>
<input type="hidden" name=e value=<?php echo $e ?>>
<input type="hidden" name=n value=<?php echo $n ?>>
<input type="hidden" name=d value=<?php echo $d ?>>
2012-02-14 18:45:18 +00:00
<table>
<tr><td><input type="submit" name="submit" value="Back"> </td></tr>
</table>
</body>
</html>