modified to work with php5

This commit is contained in:
robin 2012-02-17 13:18:51 +00:00
parent 32ef5667cf
commit 1fe3879dd2
12 changed files with 143 additions and 2 deletions

View File

@ -2,6 +2,15 @@
<body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f"> <body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f">
<h1> The Numbers </h1> <h1> The Numbers </h1>
<? <?
$e = $_POST['e'];
$d = $_POST['d'];
$p = $_POST['p'];
$n = $_POST['n'];
$q = $_POST['q'];
$phi = $_POST['phi'];
$mprivate = $_POST['mprivate'];
echo " p $p q $q"; echo " p $p q $q";
$big_num = `echo $p^$q | bc | sed -f /var/www/html/rsa/nlhtml.sed `; $big_num = `echo $p^$q | bc | sed -f /var/www/html/rsa/nlhtml.sed `;
//$big_num = `echo $p^$q | bc | sed -f /home/robin/scripts/nlhtml.sed `; //$big_num = `echo $p^$q | bc | sed -f /home/robin/scripts/nlhtml.sed `;

View File

@ -2,6 +2,13 @@
<body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f"> <body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f">
<h1> PI - calculated to required precision </h1> <h1> PI - calculated to required precision </h1>
<? <?
$e = $_POST['e'];
$d = $_POST['d'];
$p = $_POST['p'];
$n = $_POST['n'];
$q = $_POST['q'];
$phi = $_POST['phi'];
$mprivate = $_POST['mprivate'];
if ( $precision < 1 ) { $precision = 100; } if ( $precision < 1 ) { $precision = 100; }

View File

@ -1,6 +1,15 @@
<html> <html>
<body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f"> <body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f">
<? <?
$e = $_POST['e'];
$d = $_POST['d'];
$p = $_POST['p'];
$n = $_POST['n'];
$q = $_POST['q'];
$phi = $_POST['phi'];
$mprivate = $_POST['mprivate'];
echo "arggggh why wont you call this script $m $e $n<p>"; echo "arggggh why wont you call this script $m $e $n<p>";
echo `echo " a(1)*4" | bc -l `; echo `echo " a(1)*4" | bc -l `;
echo "A<p>"; echo "A<p>";

View File

@ -2,6 +2,19 @@
<body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f"> <body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f">
<h1> Encode integer 'm' </h1> <h1> Encode integer 'm' </h1>
<? <?
$c = $_POST['c'];
$m = $_POST['m'];
$e = $_POST['e'];
$e = $_POST['e'];
$d = $_POST['d'];
$p = $_POST['p'];
$n = $_POST['n'];
$q = $_POST['q'];
$phi = $_POST['phi'];
$mprivate = $_POST['mprivate'];
echo "<h1> Decodes the ciphered integer using the secret 'd' key : m = c^d mod n. </h1>\n"; echo "<h1> Decodes the ciphered integer using the secret 'd' key : m = c^d mod n. </h1>\n";
//echo "d == $d <p>"; //echo "d == $d <p>";

View File

@ -2,6 +2,16 @@
<body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f"> <body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f">
<h1> Encode integer 'm' </h1> <h1> Encode integer 'm' </h1>
<? <?
$e = $_POST['e'];
$d = $_POST['d'];
$p = $_POST['p'];
$n = $_POST['n'];
$q = $_POST['q'];
$phi = $_POST['phi'];
$mprivate = $_POST['mprivate'];
$m = $_POST['m'];
echo "<h1> in encode.php m is $m</h1>";
echo "<h1> Computes the cipher text c = m^e mod n.</h1>"; echo "<h1> Computes the cipher text c = m^e mod n.</h1>";
echo "<h3> $m^$e%$n </h3>"; echo "<h3> $m^$e%$n </h3>";
$digits = `./pow_digits $m $e`; $digits = `./pow_digits $m $e`;

View File

@ -6,6 +6,18 @@
<h1> RSA Interactive Simulator / Work Bench : Encoding data with the public Key </h1> <h1> RSA Interactive Simulator / Work Bench : Encoding data with the public Key </h1>
<? <?
$c = $_POST['c'];
$e = $_POST['e'];
$d = $_POST['d'];
$p = $_POST['p'];
$n = $_POST['n'];
$q = $_POST['q'];
$phi = $_POST['phi'];
$mprivate = $_POST['mprivate'];
$m = $_POST['m'];
//printf("<h1> in encode_pup.php m is %s </h1>",$m);
If ( $n < 1 || $e < 1 || $d < 1 ) { If ( $n < 1 || $e < 1 || $d < 1 ) {

View File

@ -2,6 +2,17 @@
<body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f"> <body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f">
<h1> Find d, the private key </h1> <h1> Find d, the private key </h1>
<? <?
$e = $_POST['e'];
$d = $_POST['d'];
$p = $_POST['p'];
$n = $_POST['n'];
$q = $_POST['q'];
$phi = $_POST['phi'];
$mprivate = $_POST['mprivate'];
printf("IN FIND D");
printf("<H1> PHI is %s</h1>",$phi);
//echo "debug n==$n"; //echo "debug n==$n";

View File

@ -2,6 +2,16 @@
<body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f"> <body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f">
<h1> Generating PHI the secret Modulus </h1> <h1> Generating PHI the secret Modulus </h1>
<? <?
$p = $_POST['p'];
$q = $_POST['q'];
$e = $_POST['e'];
$d = $_POST['d'];
$p = $_POST['p'];
$n = $_POST['n'];
$q = $_POST['q'];
$phi = $_POST['phi'];
$mprivate = $_POST['mprivate'];
$big_num = `echo "($p-1)*($q-1)" | bc `; $big_num = `echo "($p-1)*($q-1)" | bc `;

12
gcd.php
View File

@ -2,6 +2,18 @@
<body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f"> <body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f">
<h1> The Numbers </h1> <h1> The Numbers </h1>
<? <?
$e = $_POST['e'];
$d = $_POST['d'];
$p = $_POST['p'];
$n = $_POST['n'];
$q = $_POST['q'];
$phi = $_POST['phi'];
$mprivate = $_POST['mprivate'];
//echo " gcd($e,$phi) == "; //echo " gcd($e,$phi) == ";
$big_num = `echo "a=$e; b=$phi; while(b) {a=a%b; r=b; b=a; a=r;}; a;" | bc `; $big_num = `echo "a=$e; b=$phi; while(b) {a=a%b; r=b; b=a; a=r;}; a;" | bc `;

View File

@ -42,6 +42,26 @@ For full RSA simulations a <a href="bc.html"> bc </a>
and on-line <a href="bc_primes.php"> here </a>. and on-line <a href="bc_primes.php"> here </a>.
</p> </p>
<?
// for php5 must do this to catch all the variables...
$c = $_POST['c'];
$m = $_POST['m'];
$e = $_POST['e'];
$e = $_POST['e'];
$d = $_POST['d'];
$p = $_POST['p'];
$n = $_POST['n'];
$q = $_POST['q'];
$phi = $_POST['phi'];
$mprivate = $_POST['mprivate'];
?>
<br> <br> <A name="PRIME"> <br> <br> <A name="PRIME">
<hr> <hr>
<h2> FIND SUITABLE PRIMES </h2> <h2> FIND SUITABLE PRIMES </h2>

View File

@ -1,9 +1,18 @@
<html> <html>
<body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f"> <body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f">
<h1> Public Key 'Modulus' Generation </h1> <h1> Public Key 'Modulus' Generation </h1>
<? <?
$e = $_POST['e'];
$d = $_POST['d'];
$p = $_POST['p'];
$n = $_POST['n'];
$q = $_POST['q'];
$phi = $_POST['phi'];
$mprivate = $_POST['mprivate'];
$p = $_POST['p'];
$q = $_POST['q'];
$p = trim($p); $p = trim($p);
$q = trim($q); $q = trim($q);
@ -22,10 +31,12 @@ printf(" is capable of encrypting a %s bit length key </h2>",$k-1);
<form enctype="multipart/form-data" method="post" <form enctype="multipart/form-data" method="post"
action="generate_key.php#PHI"> action="generate_key.php#PHI">
<input type="hidden" name=p value=<? echo $p ?>> <input type="hidden" name=p value=<? echo $p ?>>
<input type="hidden" name=q value=<? echo $q ?>> <input type="hidden" name=q value=<? echo $q ?>>
<input type="hidden" name=n value=<? echo $n ?>> <input type="hidden" name=n value=<? echo $n ?>>
<input type="hidden" name=e value=<? echo $e ?>> <input type="hidden" name=e value=<? echo $e ?>>
<table> <table>
<tr><td><input type="submit" name="submit" value="Back"> </td></tr> <tr><td><input type="submit" name="submit" value="Back"> </td></tr>
</table> </table>

View File

@ -3,7 +3,24 @@
<? <?
// Find Primes From $i to $x // Find Primes From $i to $x
$x = $_POST['i'];
$i = $_POST['x'];
$e = $_POST['e'];
$d = $_POST['d'];
$p = $_POST['p'];
$n = $_POST['n'];
$q = $_POST['q'];
$phi = $_POST['phi'];
$mprivate = $_POST['mprivate'];
//$_POST['i']
//$_POST['x']
//
//printf(" i is %d x is %d <br>",$i,$x);
//printf(" i is %d x is %d <br>",$i,$x);
//printf(" i is %d x is %d <br>",$i,$x);
//rintf(" i is %d x is %d <br>",$i,$x);
// if they put they parameters the wrong way round... // if they put they parameters the wrong way round...