modified to work with php5
This commit is contained in:
parent
32ef5667cf
commit
1fe3879dd2
@ -2,6 +2,15 @@
|
||||
<body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f">
|
||||
<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";
|
||||
$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 `;
|
||||
|
@ -2,6 +2,13 @@
|
||||
<body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f">
|
||||
<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; }
|
||||
|
||||
|
9
cbe.php
9
cbe.php
@ -1,6 +1,15 @@
|
||||
<html>
|
||||
<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 `echo " a(1)*4" | bc -l `;
|
||||
echo "A<p>";
|
||||
|
13
decode.php
13
decode.php
@ -2,6 +2,19 @@
|
||||
<body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f">
|
||||
<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 "d == $d <p>";
|
||||
|
10
encode.php
10
encode.php
@ -2,6 +2,16 @@
|
||||
<body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f">
|
||||
<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 "<h3> $m^$e%$n </h3>";
|
||||
$digits = `./pow_digits $m $e`;
|
||||
|
@ -6,6 +6,18 @@
|
||||
<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 ) {
|
||||
|
||||
|
11
find_d.php
11
find_d.php
@ -2,6 +2,17 @@
|
||||
<body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f">
|
||||
<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";
|
||||
|
||||
|
10
find_phi.php
10
find_phi.php
@ -2,6 +2,16 @@
|
||||
<body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f">
|
||||
<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 `;
|
||||
|
||||
|
12
gcd.php
12
gcd.php
@ -2,6 +2,18 @@
|
||||
<body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f">
|
||||
<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) == ";
|
||||
|
||||
$big_num = `echo "a=$e; b=$phi; while(b) {a=a%b; r=b; b=a; a=r;}; a;" | bc `;
|
||||
|
@ -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>.
|
||||
</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">
|
||||
<hr>
|
||||
<h2> FIND SUITABLE PRIMES </h2>
|
||||
|
15
multiply.php
15
multiply.php
@ -1,9 +1,18 @@
|
||||
|
||||
|
||||
<html>
|
||||
<body BGCOLOR="#00E0E0" link="#001fC0" vlink="#000080" text="#00000f">
|
||||
<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);
|
||||
$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"
|
||||
action="generate_key.php#PHI">
|
||||
|
||||
<input type="hidden" name=p value=<? echo $p ?>>
|
||||
<input type="hidden" name=q value=<? echo $q ?>>
|
||||
<input type="hidden" name=n value=<? echo $n ?>>
|
||||
<input type="hidden" name=e value=<? echo $e ?>>
|
||||
|
||||
<table>
|
||||
<tr><td><input type="submit" name="submit" value="Back"> </td></tr>
|
||||
</table>
|
||||
|
17
primes.php
17
primes.php
@ -3,7 +3,24 @@
|
||||
|
||||
<?
|
||||
// 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...
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user