mirror of
https://github.com/phpseclib/phpseclib.git
synced 2024-12-25 03:16:02 +00:00
BigInteger/GMP: use gmp_import / gmp_export
This commit is contained in:
parent
5801806d23
commit
6f6b93b012
@ -53,7 +53,7 @@
|
||||
"require": {
|
||||
"paragonie/constant_time_encoding": "^1",
|
||||
"paragonie/random_compat": "^1.4|^2.0",
|
||||
"php": ">=5.6"
|
||||
"php": ">=5.6.1"
|
||||
},
|
||||
"require-dev": {
|
||||
"phing/phing": "~2.7",
|
||||
|
@ -137,7 +137,7 @@ class GMP extends Engine
|
||||
switch (abs($base)) {
|
||||
case 256:
|
||||
$sign = $this->is_negative ? '-' : '';
|
||||
$this->value = gmp_init($sign . '0x' . Hex::encode($this->value));
|
||||
$this->value = gmp_import($this->value);
|
||||
break;
|
||||
case 16:
|
||||
$temp = $this->is_negative ? '-0x' . $this->value : '0x' . $this->value;
|
||||
@ -174,9 +174,7 @@ class GMP extends Engine
|
||||
return $this->precision > 0 ? str_repeat(chr(0), ($this->precision + 1) >> 3) : '';
|
||||
}
|
||||
|
||||
$temp = gmp_strval(gmp_abs($this->value), 16);
|
||||
$temp = (strlen($temp) & 1) ? '0' . $temp : $temp;
|
||||
$temp = Hex::decode($temp);
|
||||
$temp = gmp_export($this->value);
|
||||
|
||||
return $this->precision > 0 ?
|
||||
substr(str_pad($temp, $this->precision >> 3, chr(0), STR_PAD_LEFT), -($this->precision >> 3)) :
|
||||
|
Loading…
Reference in New Issue
Block a user