Encode integer 'm'
echo " Decodes the ciphered integer using the secret 'd' key : m = c^d mod n.
\n";
//echo "d == $d ";
//echo "c == $c
";
//echo "digits = $digits
";
//echo "\n\n\n\n\n";
//$gt100k = `./gt100k $digits`;
//if ($gt100k != 1)
//echo "
c^d ==
";
// check here that the exponentiation can actually be displayed
// and use the recursive algorithms if it cannot
// along with a warning about the length of time it could take.
$digits = `./pow_digits $c $d `;
$gt100_k = `./gt100k $digits`;
//echo "./gt100k $digits";
//echo " gt100_k == $gt100_k";
$date = `date`;
printf(" Start Time == %s
\n",$date);
if ($gt100_k != 1) {
echo " The predicted number of digits from the exponentiation is less than 100,000.
It can therefore be shown in full ";
$c_to_d = `echo " $c ^ $d " | bc | sed -f ./nlhtml.sed `;
echo $c_to_d;
`echo " $c ^ $d " | bc | sed -f ./nlhtml.sed `;
echo " % $n
";
echo "
this gives the 'in clear' result
";
$clear = `echo " ( $c ^ $d ) % $n " | bc | sed -f ./nlhtml.sed `;
echo $clear;
}
else {
echo " The number of digits produced by the exponentiation of c^d is greater than 100,0000
";
echo " The resursive (see recursive exponentiation break down ) routines will be applied instead to calculate c^d%n
";
$clear = `./cbe.sh 'A $c B $d C $n D'`; // php is very nasty about sending multiple args to scripts
echo " this gives the 'in clear' result
";
echo $clear;
}
$date = `date`;
printf(" End Time == %s
\n",$date);
printf("