[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/vendor/phpseclib/phpseclib/phpseclib/Math/BigInteger/Engines/ -> PHP64.php (summary)

Pure-PHP 64-bit BigInteger Engine PHP version 5 and 7

Author: Jim Wigginton
Copyright: 2017 Jim Wigginton
License: http://www.opensource.org/licenses/mit-license.html MIT License
Link: http://pear.php.net/package/Math_BigInteger
File Size: 372 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

PHP64:: (22 methods):
  initialize()
  isValidEngine()
  add()
  subtract()
  multiply()
  divide()
  modInverse()
  extendedGCD()
  gcd()
  bitwise_and()
  bitwise_or()
  bitwise_xor()
  compare()
  equals()
  modPow()
  powMod()
  randomRangePrime()
  randomRange()
  pow()
  min()
  max()
  between()


Class: PHP64  - X-Ref

Pure-PHP 64-bit Engine.

Uses 64-bit integers if int size is 8 bits

initialize($base)   X-Ref
Initialize a PHP64 BigInteger Engine instance

see: parent::initialize()
param: int $base

isValidEngine()   X-Ref
Test for engine validity

see: parent::__construct()
return: bool

add(PHP64 $y)   X-Ref
Adds two BigIntegers.

return: PHP64
param: PHP64 $y

subtract(PHP64 $y)   X-Ref
Subtracts two BigIntegers.

return: PHP64
param: PHP64 $y

multiply(PHP64 $y)   X-Ref
Multiplies two BigIntegers.

return: PHP64
param: PHP64 $y

divide(PHP64 $y)   X-Ref
Divides two BigIntegers.

Returns an array whose first element contains the quotient and whose second element contains the
"common residue".  If the remainder would be positive, the "common residue" and the remainder are the
same.  If the remainder would be negative, the "common residue" is equal to the sum of the remainder
and the divisor (basically, the "common residue" is the first positive modulo).

return: array{PHP64, PHP64}
param: PHP64 $y

modInverse(PHP64 $n)   X-Ref
Calculates modular inverses.

Say you have (30 mod 17 * x mod 17) mod 17 == 1.  x can be found using modular inverses.
return: false|PHP64
param: PHP64 $n

extendedGCD(PHP64 $n)   X-Ref
Calculates modular inverses.

Say you have (30 mod 17 * x mod 17) mod 17 == 1.  x can be found using modular inverses.
return: PHP64[]
param: PHP64 $n

gcd(PHP64 $n)   X-Ref
Calculates the greatest common divisor

Say you have 693 and 609.  The GCD is 21.

return: PHP64
param: PHP64 $n

bitwise_and(PHP64 $x)   X-Ref
Logical And

return: PHP64
param: PHP64 $x

bitwise_or(PHP64 $x)   X-Ref
Logical Or

return: PHP64
param: PHP64 $x

bitwise_xor(PHP64 $x)   X-Ref
Logical Exclusive Or

return: PHP64
param: PHP64 $x

compare(PHP64 $y)   X-Ref
Compares two numbers.

Although one might think !$x->compare($y) means $x != $y, it, in fact, means the opposite.  The reason for this is
demonstrated thusly:

$x  > $y: $x->compare($y)  > 0
$x  < $y: $x->compare($y)  < 0
$x == $y: $x->compare($y) == 0

Note how the same comparison operator is used.  If you want to test for equality, use $x->equals($y).

{@internal Could return $this->subtract($x), but that's not as fast as what we do do.}

see: self::equals()
return: int in case < 0 if $this is less than $y; > 0 if $this is greater than $y, and 0 if they are equal.
param: PHP64 $y

equals(PHP64 $x)   X-Ref
Tests the equality of two numbers.

If you need to see if one number is greater than or less than another number, use BigInteger::compare()

return: bool
param: PHP64 $x

modPow(PHP64 $e, PHP64 $n)   X-Ref
Performs modular exponentiation.

return: PHP64
param: PHP64 $e
param: PHP64 $n

powMod(PHP64 $e, PHP64 $n)   X-Ref
Performs modular exponentiation.

Alias for modPow().

return: PHP64|false
param: PHP64 $e
param: PHP64 $n

randomRangePrime(PHP64 $min, PHP64 $max)   X-Ref
Generate a random prime number between a range

If there's not a prime within the given range, false will be returned.

return: false|PHP64
param: PHP64 $min
param: PHP64 $max

randomRange(PHP64 $min, PHP64 $max)   X-Ref
Generate a random number between a range

Returns a random number between $min and $max where $min and $max
can be defined using one of the two methods:

BigInteger::randomRange($min, $max)
BigInteger::randomRange($max, $min)

return: PHP64
param: PHP64 $min
param: PHP64 $max

pow(PHP64 $n)   X-Ref
Performs exponentiation.

return: PHP64
param: PHP64 $n

min(PHP64 ...$nums)   X-Ref
Return the minimum BigInteger between an arbitrary number of BigIntegers.

return: PHP64
param: PHP64 ...$nums

max(PHP64 ...$nums)   X-Ref
Return the maximum BigInteger between an arbitrary number of BigIntegers.

return: PHP64
param: PHP64 ...$nums

between(PHP64 $min, PHP64 $max)   X-Ref
Tests BigInteger to see if it is between two integers, inclusive

return: bool
param: PHP64 $min
param: PHP64 $max