lockfile again

This commit is contained in:
Tim Bendt
2025-11-26 11:50:55 -05:00
parent af3c23cb6e
commit 6ceecaa69e
4461 changed files with 641349 additions and 10 deletions

View File

@@ -0,0 +1,30 @@
<?php
/*
On a 1.6GHz Pentium M, the following takes about 1.33 seconds with the pure-PHP implementation,
0.66 seconds with BCmath, and 0.001 seconds with GMP.
*/
require(__DIR__.'/../vendor/autoload.php');
//define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_INTERNAL);
//define('MATH_BIGINTEGER_MODE', MATH_BIGINTEGER_MODE_BCMATH);
$a = '0b078d385e9d05d9e029dc9732e75f94f59fdcfb989fe25e81edcb4f93c1dc53a9bb6ba09b5799bd' .
'aa9e35cd4e00a8200b720d9c6034da9819a5c84e3c7106fcdf5e64c975221bfd9b606bf924bc2971' .
'de66c470b88221b419ad32e0bff8fb234cbfa0f99e0909d46855a6751b7660b7178f0a661265ad23' .
'8433331edb99e0ff';
$b = 'a6b9ac382a5f8d394ee83d9e6e21e993c8d240e1';
$c = 'aebbcd9a69b5116ce60400b4126c9e84173635abde4bfa56da904e75d752a51a47d3f088f13299a0' .
'3b6bf66bf77a6accddeb16fc46a8a32164d7fad2ce4bb159e5caeddb40c25ae02c19e7426bd26398' .
'14d36ead09509031fc423852c33ff0e6d402b2af825acc03ad6ad234eb5d269c17a026bd37c1b6e2' .
'4c8c7248d09e12ef';
$a = new Math_BigInteger($a, 16);
$b = new Math_BigInteger($b, 16);
$c = new Math_BigInteger($c, 16);
$start = microtime(true);
$d = $a->modPow($b, $c);
$elapsed = microtime(true) - $start;
echo "took $elapsed seconds\r\n";
echo md5($d->toString()); // should equal aab326a2511ee857e16ce0cdd3243779

View File

@@ -0,0 +1,73 @@
<?php
// $Id$
// Example of how to use of BigInteger. The output can be compared to the output that the BCMath functions would yield.
// bcpowmod is included with Math_BigInteger.php via PHP_Compat.
require(__DIR__.'/../vendor/autoload.php');
$x = mt_rand(1,10000000);
$y = mt_rand(1,10000000);
$z = mt_rand(1,10000000);
$_x = new Math_BigInteger($x);
$_y = new Math_BigInteger($y);
$_z = new Math_BigInteger($z);
echo "\$x = $x;\r\n";
echo "\$y = $y;\r\n";
echo "\$z = $z;\r\n";
echo "\r\n";
$result = bcadd($x,$y);
$_result = $_x->add($_y);
echo "\$result = \$x+\$y;\r\n";
echo "$result\r\n";
echo $_result->toString();
echo "\r\n\r\n";
$result = bcsub($result,$y);
$_result = $_result->subtract($_y);
echo "\$result = \$result-\$y;\r\n";
echo "$result\r\n";
echo $_result->toString();
echo "\r\n\r\n";
$result = bcdiv($x,$y);
list($_result,) = $_x->divide($_y);
echo "\$result = \$x/\$y;\r\n";
echo "$result\r\n";
echo $_result->toString();
echo "\r\n\r\n";
$result = bcmod($y,$z);
list(,$_result) = $_y->divide($_z);
echo "\$result = \$x%\$y;\r\n";
echo "$result\r\n";
echo $_result->toString();
echo "\r\n\r\n";
$result = bcmul($x,$z);
$_result = $_x->multiply($_z);
echo "\$result = \$x*\$z;\r\n";
echo "$result\r\n";
echo $_result->toString();
echo "\r\n\r\n";
$result = bcpowmod($x,$y,$result);
$_result = $_x->modPow($_y,$_result);
echo "\$result = (\$x**\$y)%\$result;\r\n";
echo "$result\r\n";
echo $_result->toString();
echo "\r\n\r\n";
// modInverse isn't demo'd because no equivalent to it exists in BCMath.
?>