new appraoch
This commit is contained in:
3717
pancake/system/vendor/pear/math_biginteger/Math/BigInteger.php
vendored
Executable file
3717
pancake/system/vendor/pear/math_biginteger/Math/BigInteger.php
vendored
Executable file
File diff suppressed because it is too large
Load Diff
39
pancake/system/vendor/pear/math_biginteger/README.rst
vendored
Executable file
39
pancake/system/vendor/pear/math_biginteger/README.rst
vendored
Executable file
@@ -0,0 +1,39 @@
|
||||
***************
|
||||
Math_BigInteger
|
||||
***************
|
||||
Pure-PHP arbitrary precision integer arithmetic library.
|
||||
|
||||
Supports base-2, base-10, base-16, and base-256 numbers.
|
||||
Uses the GMP or BCMath extensions, if available, and an internal implementation,
|
||||
otherwise.
|
||||
|
||||
|
||||
Installation
|
||||
============
|
||||
|
||||
PEAR
|
||||
----
|
||||
::
|
||||
|
||||
$ pear install Math_BigInteger
|
||||
|
||||
Composer
|
||||
--------
|
||||
::
|
||||
|
||||
$ composer require pear/math_biginteger
|
||||
|
||||
|
||||
Usage
|
||||
=====
|
||||
See the examples in the ``demo/`` directory.
|
||||
|
||||
|
||||
Links
|
||||
=====
|
||||
Homepage
|
||||
http://pear.php.net/package/Math_BigInteger
|
||||
Bug tracker
|
||||
http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Math_BigInteger
|
||||
Source code
|
||||
https://github.com/pear/Math_BigInteger
|
||||
37
pancake/system/vendor/pear/math_biginteger/composer.json
vendored
Executable file
37
pancake/system/vendor/pear/math_biginteger/composer.json
vendored
Executable file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
"name": "pear/math_biginteger",
|
||||
"description": "Pure-PHP arbitrary precission integer arithmetic library. If GMP or BCMath are available they are used.",
|
||||
"type": "library",
|
||||
"keywords": [
|
||||
"integer",
|
||||
"arbitrary",
|
||||
"precision",
|
||||
"bcmath",
|
||||
"gmp"
|
||||
],
|
||||
"homepage": "https://github.com/pear/Math_BigInteger",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Jim Wigginton",
|
||||
"email": "terrafrost@php.net"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=4.2.0",
|
||||
"ext-pcre": "*"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-bcmath": "Allows using the BCMath extension internally for computation. Faster than native implementation.",
|
||||
"ext-gmp": "Allows using the GNU Multiple Precision extension internally for computation. If you are doing a lot of computation this is the recommended extension."
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Math_": "./"
|
||||
}
|
||||
},
|
||||
"support": {
|
||||
"issues": "http://pear.php.net/bugs/search.php?cmd=display&package_name[]=Math_BigInteger",
|
||||
"source": "https://github.com/pear/Math_BigInteger"
|
||||
}
|
||||
}
|
||||
30
pancake/system/vendor/pear/math_biginteger/demo/benchmark.php
vendored
Executable file
30
pancake/system/vendor/pear/math_biginteger/demo/benchmark.php
vendored
Executable 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
|
||||
73
pancake/system/vendor/pear/math_biginteger/demo/demo.php
vendored
Executable file
73
pancake/system/vendor/pear/math_biginteger/demo/demo.php
vendored
Executable 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.
|
||||
|
||||
?>
|
||||
152
pancake/system/vendor/pear/math_biginteger/package.xml
vendored
Executable file
152
pancake/system/vendor/pear/math_biginteger/package.xml
vendored
Executable file
@@ -0,0 +1,152 @@
|
||||
<?xml version="1.0"?>
|
||||
<package version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<name>Math_BigInteger</name>
|
||||
<channel>pear.php.net</channel>
|
||||
<summary>Pure-PHP arbitrary precission integer arithmetic library</summary>
|
||||
<description>
|
||||
Supports base-2, base-10, base-16, and base-256 numbers. Uses the GMP or BCMath extensions, if available, and an internal implementation, otherwise.
|
||||
</description>
|
||||
<lead>
|
||||
<name>Jim Wigginton</name>
|
||||
<user>terrafrost</user>
|
||||
<email>terrafrost@php.net</email>
|
||||
<active>yes</active>
|
||||
</lead>
|
||||
<date>2016-04-12</date>
|
||||
<version>
|
||||
<release>1.0.3</release>
|
||||
<api>1.0.3</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://www.opensource.org/licenses/mit-license.html">MIT</license>
|
||||
<notes>
|
||||
- Fix PHP7 constructor deprecation notice
|
||||
</notes>
|
||||
<contents>
|
||||
<dir name="/">
|
||||
<file name="Math/BigInteger.php" role="php" />
|
||||
<file baseinstalldir="Math/BigInteger" name="demo/demo.php" role="php" />
|
||||
<file baseinstalldir="Math/BigInteger" name="demo/benchmark.php" role="php" />
|
||||
</dir>
|
||||
</contents>
|
||||
<dependencies>
|
||||
<required>
|
||||
<php>
|
||||
<min>4.2</min>
|
||||
</php>
|
||||
<pearinstaller>
|
||||
<min>1.4.0</min>
|
||||
</pearinstaller>
|
||||
<extension>
|
||||
<name>pcre</name>
|
||||
</extension>
|
||||
</required>
|
||||
</dependencies>
|
||||
<phprelease />
|
||||
<changelog>
|
||||
|
||||
<release>
|
||||
<version>
|
||||
<release>1.0.0RC1</release>
|
||||
<api>1.0.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>beta</release>
|
||||
<api>beta</api>
|
||||
</stability>
|
||||
<date>2006-10-26</date>
|
||||
<license uri="http://www.gnu.org/licenses/lgpl.html">LGPL</license>
|
||||
<notes>Initial PEAR release.</notes>
|
||||
</release>
|
||||
|
||||
<release>
|
||||
<version>
|
||||
<release>1.0.0RC2</release>
|
||||
<api>1.0.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>beta</release>
|
||||
<api>beta</api>
|
||||
</stability>
|
||||
<date>2006-11-16</date>
|
||||
<license uri="http://www.gnu.org/licenses/lgpl.html">LGPL</license>
|
||||
<notes>
|
||||
Added bitwise_or(), bitwise_and(), bitwise_xor(), and bitwise_not()
|
||||
</notes>
|
||||
</release>
|
||||
|
||||
<release>
|
||||
<version>
|
||||
<release>1.0.0RC3</release>
|
||||
<api>1.0.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>beta</release>
|
||||
<api>beta</api>
|
||||
</stability>
|
||||
<date>2007-02-05</date>
|
||||
<license uri="http://www.gnu.org/licenses/lgpl.html">LGPL</license>
|
||||
<notes>
|
||||
- Fix for bug #9654: In MODE_INTERNAL, modPow doesn't work occasionally
|
||||
- Other bug fixes
|
||||
</notes>
|
||||
</release>
|
||||
|
||||
<release>
|
||||
<version>
|
||||
<release>1.0.0</release>
|
||||
<api>1.0.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2010-05-26</date>
|
||||
<license uri="http://www.gnu.org/licenses/lgpl.html">LGPL</license>
|
||||
<notes>
|
||||
- significant speed-ups
|
||||
- new functions: gcd(), extendedGCD(), isPrime(), random(), randomPrime(), bitwise_leftRotate(), bitwise_rightRotate(), setPrecision(), toHex(), toBits() and equals()
|
||||
- PHP_Compat is now optional. Store it in your include path if you require PHP4 support but otherwise it is unrequired.
|
||||
</notes>
|
||||
</release>
|
||||
|
||||
<release>
|
||||
<version>
|
||||
<release>1.0.2</release>
|
||||
<api>1.0.0</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2014-02-11</date>
|
||||
<license uri="http://www.opensource.org/licenses/mit-license.html">MIT</license>
|
||||
<notes>
|
||||
- (internal, bcmath) use OpenSSL, if available, for modular exponentiation
|
||||
- (internal) use 64-bit ints, if available, and 64-bit floats, otherwise
|
||||
- (all) improve random number generation
|
||||
- change license to less restrictive MIT license
|
||||
</notes>
|
||||
</release>
|
||||
|
||||
<release>
|
||||
<version>
|
||||
<release>1.0.3</release>
|
||||
<api>1.0.3</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<date>2016-04-12</date>
|
||||
<license uri="http://www.opensource.org/licenses/mit-license.html">MIT</license>
|
||||
<notes>
|
||||
- Fix PHP7 constructor deprecation notice
|
||||
</notes>
|
||||
</release>
|
||||
|
||||
</changelog>
|
||||
</package>
|
||||
Reference in New Issue
Block a user