1
0
mirror of https://github.com/danog/PrimeModule.git synced 2024-11-26 20:34:37 +01:00
This commit is contained in:
danogentili 2017-02-25 13:40:07 +03:00
parent 2cb6f19283
commit b82d23143e
4 changed files with 10 additions and 9 deletions

View File

@ -37,15 +37,15 @@ class Struct
* Packs data into bytes
*
* @param $format Format string
* @param ...$data Parameters to encode
* @param $data Parameters to encode
*
* @return Encoded data
*/
public static function pack($format, ...$data)
public static function pack($format, $data)
{
self::constructor();
return self::$struct->pack($format, ...$data);
return self::$struct->pack($format, $data);
}
/**

View File

@ -38,11 +38,11 @@ class StructClass
*
* Packs data into bytes
*
* @param ...$data Parameters to encode (may contain format string)
* @param $data Parameters to encode (may contain format string)
*
* @return Encoded data
*/
public function pack(...$data)
public function pack($data)
{
if ($this->format === null) {
$format = array_shift($data);
@ -50,7 +50,7 @@ class StructClass
$format = $this->format;
}
return $this->struct->pack($format, ...$data);
return $this->struct->pack($format, $data);
}
/**

View File

@ -249,12 +249,13 @@ class StructTools
* Packs data into bytes
*
* @param $format Format string
* @param ...$data Parameters to encode
* @param $data Parameters to encode
*
* @return Encoded data
*/
public function pack($format, ...$data)
public function pack($format, $data)
{
$data = [$data];
$format = $this->padformat($format);
$result = null; // Data to return
$size = $this->calcsize($format);

View File

@ -80,7 +80,7 @@ function random_string($length)
}
function gen_payload()
{
return \danog\PHP\Struct::pack('<Bqqii', 10, 0, (int) (time() << 32), 20, 1615239032).random_string(16);
return chr(10).str_repeat(chr(0), 8).\danog\PHP\Struct::pack('<q', (int) (time() << 32)).pack('VV', 20, 1615239032).random_string(16);
}
echo PHP_EOL.'----------- HUGE SEMIPRIME TESTS (100 semiprimes) ----------'.PHP_EOL;