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
|
||||
{
|
||||
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(string|array $body, string|bool $password = false)
|
||||
public function signBody($body, $password = false)
|
||||
{
|
||||
$privateKey = PublicKeyLoader::loadPrivateKey(base64_decode($this->privateKey), $password);
|
||||
$sig = $privateKey->sign(json_encode($body));
|
||||
return base64_encode($sig);
|
||||
}
|
||||
|
||||
public function verifySignature(string $signature, string|array $message, $key)
|
||||
public function verifySignature($signature, $message, $key)
|
||||
{
|
||||
$publicKey = PublicKeyLoader::loadPublicKey($key);
|
||||
return $publicKey->verify(json_encode($message), $signature);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue