mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-09 15:29:47 +00:00
EncryptionContext: fixed a phpstan level 7 error (openssl_digest() might return false for god knows what reason)
This commit is contained in:
parent
edc3156bea
commit
95114dcc1e
@ -27,6 +27,7 @@ use Crypto\Cipher;
|
||||
use pocketmine\utils\Binary;
|
||||
use function bin2hex;
|
||||
use function openssl_digest;
|
||||
use function openssl_error_string;
|
||||
use function strlen;
|
||||
use function substr;
|
||||
|
||||
@ -86,6 +87,10 @@ class EncryptionContext{
|
||||
}
|
||||
|
||||
private function calculateChecksum(int $counter, string $payload) : string{
|
||||
return substr(openssl_digest(Binary::writeLLong($counter) . $payload . $this->key, self::CHECKSUM_ALGO, true), 0, 8);
|
||||
$hash = openssl_digest(Binary::writeLLong($counter) . $payload . $this->key, self::CHECKSUM_ALGO, true);
|
||||
if($hash === false){
|
||||
throw new \RuntimeException("Encryption error: " . openssl_error_string());
|
||||
}
|
||||
return substr($hash, 0, 8);
|
||||
}
|
||||
}
|
||||
|
@ -645,11 +645,6 @@ parameters:
|
||||
count: 1
|
||||
path: ../../../src/network/mcpe/encryption/EncryptionUtils.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$str of function substr expects string, string\\|false given\\.$#"
|
||||
count: 1
|
||||
path: ../../../src/network/mcpe/encryption/NetworkCipher.php
|
||||
|
||||
-
|
||||
message: "#^Parameter \\#1 \\$v of method pocketmine\\\\utils\\\\BinaryStream\\:\\:putBool\\(\\) expects bool, bool\\|float\\|int given\\.$#"
|
||||
count: 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user