Skip to content

Commit

Permalink
Updated phpseclib to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
DoctorMcKay committed Sep 10, 2021
1 parent 8afa799 commit 6cd00fb
Show file tree
Hide file tree
Showing 3 changed files with 256 additions and 9 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "PHP SteamID Manipulation",
"type": "library",
"require": {
"phpseclib/phpseclib": "0.3.10"
"phpseclib/phpseclib": "^3.0.10"
},
"license": "MIT",
"authors": [
Expand Down
247 changes: 247 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 8 additions & 8 deletions src/SteamID.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace SteamID;

use Exception;
use Math_BigInteger;
use phpseclib3\Math\BigInteger;


/**
Expand Down Expand Up @@ -145,11 +145,11 @@ public function __construct($id = null) {
// SteamID64
if (PHP_INT_SIZE == 4) {
// Wrapper for BigInteger
$bigint = new Math_BigInteger($id);
$bigint = new BigInteger($id);
$this->universe = (int) $bigint->bitwise_rightShift(56)->toString();
$this->type = ((int) $bigint->bitwise_rightShift(52)->toString()) & 0xF;
$this->instance = ((int) $bigint->bitwise_rightShift(32)->toString()) & 0xFFFFF;
$this->accountid = (int) $bigint->bitwise_and(new Math_BigInteger('0xFFFFFFFF', 16))->toString();
$this->accountid = (int) $bigint->bitwise_and(new BigInteger('0xFFFFFFFF', 16))->toString();
} else {
$this->universe = $id >> 56;
$this->type = ($id >> 52) & 0xF;
Expand Down Expand Up @@ -230,11 +230,11 @@ public function getSteam3RenderedID() {
*/
public function getSteamID64() {
if (PHP_INT_SIZE == 4) {
$ret = new Math_BigInteger();
$ret = $ret->add((new Math_BigInteger($this->universe))->bitwise_leftShift(56));
$ret = $ret->add((new Math_BigInteger($this->type))->bitwise_leftShift(52));
$ret = $ret->add((new Math_BigInteger($this->instance))->bitwise_leftShift(32));
$ret = $ret->add(new Math_BigInteger($this->accountid));
$ret = new BigInteger();
$ret = $ret->add((new BigInteger($this->universe))->bitwise_leftShift(56));
$ret = $ret->add((new BigInteger($this->type))->bitwise_leftShift(52));
$ret = $ret->add((new BigInteger($this->instance))->bitwise_leftShift(32));
$ret = $ret->add(new BigInteger($this->accountid));
return $ret->toString();
}
return (string) (($this->universe << 56) | ($this->type << 52) | ($this->instance << 32) | ($this->accountid));
Expand Down

0 comments on commit 6cd00fb

Please sign in to comment.