mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-11-18 03:05:11 +00:00
Merge branch '2.0'
This commit is contained in:
commit
44ac8f3996
@ -387,7 +387,7 @@ class GMP extends Engine
|
||||
public function bitwise_xor(GMP $x)
|
||||
{
|
||||
$temp = new self();
|
||||
$temp->value = $this->value ^ $x->value;
|
||||
$temp->value = gmp_abs($this->value) ^ gmp_abs($x->value);
|
||||
|
||||
return $this->normalize($temp);
|
||||
}
|
||||
|
@ -938,6 +938,7 @@ abstract class PHP extends Engine
|
||||
{
|
||||
$length = max(count($this->value), count($x->value));
|
||||
$result = clone $this;
|
||||
$result->is_negative = false;
|
||||
$result->value = array_pad($result->value, $length, 0);
|
||||
$x->value = array_pad($x->value, $length, 0);
|
||||
|
||||
|
@ -198,6 +198,18 @@ abstract class Unit_Math_BigInteger_TestCase extends PhpseclibTestCase
|
||||
$z = $this->getInstance('BC98BC98BC98BC98BC98BC98', 16);
|
||||
|
||||
$this->assertSame($z->toHex(), $x->bitwise_XOR($y)->toHex());
|
||||
|
||||
// @group github1245
|
||||
|
||||
$a = $this->getInstance(1);
|
||||
$b = $this->getInstance(-2);
|
||||
$c = $a->bitwise_xor($b);
|
||||
$this->assertSame("$c", '3');
|
||||
|
||||
$a = $this->getInstance('-6725760161961546982');
|
||||
$b = $this->getInstance(51);
|
||||
$c = $a->bitwise_xor($b);
|
||||
$this->assertSame("$c", '6725760161961546965');
|
||||
}
|
||||
|
||||
public function testBitwiseNOT()
|
||||
|
Loading…
Reference in New Issue
Block a user