Rework to be compatible with PHP 7.*
This commit is contained in:
parent
de8c7b4ac4
commit
480cc208d7
1 changed files with 8 additions and 4 deletions
12
src/Kore.php
12
src/Kore.php
|
@ -7,17 +7,21 @@ use phpseclib3\Crypt\PublicKeyLoader;
|
||||||
class Kore
|
class Kore
|
||||||
{
|
{
|
||||||
private $url = 'https://httpbin.org';
|
private $url = 'https://httpbin.org';
|
||||||
|
public $privateKey;
|
||||||
|
public $drone;
|
||||||
|
public function __construct($privateKey, $drone) {
|
||||||
|
$this->privateKey = $privateKey;
|
||||||
|
$this->drone = $drone;
|
||||||
|
}
|
||||||
|
|
||||||
public function __construct(public $privateKey, public $drone) {}
|
public function signBody($body, $password = false)
|
||||||
|
|
||||||
public function signBody(string|array $body, string|bool $password = false)
|
|
||||||
{
|
{
|
||||||
$privateKey = PublicKeyLoader::loadPrivateKey(base64_decode($this->privateKey), $password);
|
$privateKey = PublicKeyLoader::loadPrivateKey(base64_decode($this->privateKey), $password);
|
||||||
$sig = $privateKey->sign(json_encode($body));
|
$sig = $privateKey->sign(json_encode($body));
|
||||||
return base64_encode($sig);
|
return base64_encode($sig);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function verifySignature(string $signature, string|array $message, $key)
|
public function verifySignature($signature, $message, $key)
|
||||||
{
|
{
|
||||||
$publicKey = PublicKeyLoader::loadPublicKey($key);
|
$publicKey = PublicKeyLoader::loadPublicKey($key);
|
||||||
return $publicKey->verify(json_encode($message), $signature);
|
return $publicKey->verify(json_encode($message), $signature);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue