Applied fixes from StyleCI

This commit is contained in:
Daniil Gentili 2016-07-29 11:19:34 -04:00 committed by StyleCI Bot
parent 5bfb6a3b7e
commit 652327fecd
3 changed files with 15 additions and 10 deletions

View File

@ -135,8 +135,8 @@ function pyjslib_range($start, $stop = null, $step = 1)
return array_reverse($arr, false);
}
if($step > 1 && $step > ($stop - $start)) {
$arr = [ $start ];
if ($step > 1 && $step > ($stop - $start)) {
$arr = [$start];
} else {
$arr = range($start, $stop, $step);
array_pop($arr);

View File

@ -111,7 +111,7 @@ function fopen_and_write($filename, $mode, $data)
function long_to_bytes($n, $blocksize = 0)
{
$s = null;
$n = (float)$n;
$n = (float) $n;
while ($n > 0) {
$s = $GLOBALS['struct']->pack('I', $n & 4294967295).$s;
$n = $n >> 32;
@ -123,7 +123,7 @@ function long_to_bytes($n, $blocksize = 0)
break;
}
}
if(!$break) {
if (!$break) {
$s = string2bin('\000');
$i = 0;
}
@ -270,7 +270,7 @@ class Session
$this->send_message($this->tl->serialize_method($method, $kwargs));
$server_answer = $this->recv_message();
} catch (Exception $e) {
echo "An error occurred while calling method " . $method . ": " . $e->getMessage().PHP_EOL."Stack trace:" . $e->getTraceAsString() . PHP_EOL. "Retrying to call method...".PHP_EOL.PHP_EOL;
echo 'An error occurred while calling method '.$method.': '.$e->getMessage().PHP_EOL.'Stack trace:'.$e->getTraceAsString().PHP_EOL.'Retrying to call method...'.PHP_EOL.PHP_EOL;
continue;
}
@ -288,7 +288,8 @@ class Session
$pq_bytes = $ResPQ['pq'];
$pq = new \phpseclib\Math\BigInteger($pq_bytes, 256);
var_dump($this->PrimeModule->primefactors($pq));die;
var_dump($this->PrimeModule->primefactors($pq));
die;
var_dump($this->PrimeModule->pollard_brent(15));
var_dump($this->PrimeModule->primefactors(1724114033281923457));
var_dump($this->PrimeModule->primefactors(378221), $this->PrimeModule->primefactors(15));

View File

@ -13,6 +13,7 @@ class PrimeModule
$this->_smallprimeset = 100000;
$this->smallprimes = $this->primesbelow(10000);
}
public function primesbelow($N)
{
$res = [];
@ -64,7 +65,9 @@ class PrimeModule
$break = true;
}
}
if(!$break) return false;
if (!$break) {
return false;
}
}
return true;
@ -82,7 +85,7 @@ class PrimeModule
$max = new \phpseclib\Math\BigInteger($n - 1);
$min = new \phpseclib\Math\BigInteger(1);
list($y, $c, $m) = [(int)$big->random($min, $max)->toString(), (int)$big->random($min, $max)->toString(), (int)$big->random($min, $max)->toString()];
list($y, $c, $m) = [(int) $big->random($min, $max)->toString(), (int) $big->random($min, $max)->toString(), (int) $big->random($min, $max)->toString()];
list($g, $r, $q) = [1, 1, 1];
while ($g == 1) {
$x = $y;
@ -117,8 +120,9 @@ class PrimeModule
public function primefactors($n, $sort = false)
{
$factors = [];
if($n->compare(PHP_INT_MAX) === -1)
var_dump((int)$n->toString());
if ($n->compare(PHP_INT_MAX) === -1) {
var_dump((int) $n->toString());
}
$limit = ((int) (pow($n, 0.5)) + 1);
foreach ($this->smallprimes as $checker) {
if (($checker > $limit)) {