improvements
This commit is contained in:
parent
3472b19591
commit
17ebac8300
1 changed files with 5 additions and 6 deletions
11
src/Kore.php
11
src/Kore.php
|
@ -14,18 +14,17 @@ class Kore
|
|||
|
||||
public function __construct() {}
|
||||
|
||||
public function signBody($body, string|array $key, string|bool $password = false)
|
||||
public function signBody(string|array $body, string|array $key, string|bool $password = false)
|
||||
{
|
||||
$privateKey = PublicKeyLoader::loadPrivateKey(base64_decode($key), $password);
|
||||
$sig = $privateKey->sign($body);
|
||||
$sig = base64_encode($sig);
|
||||
return $sig;
|
||||
$sig = $privateKey->sign(json_encode($body));
|
||||
return base64_encode($sig);
|
||||
}
|
||||
|
||||
public function verifySignature($signature, $message, $key)
|
||||
public function verifySignature(string $signature, string|array $message, $key)
|
||||
{
|
||||
$publicKey = PublicKeyLoader::loadPublicKey($key);
|
||||
return $publicKey->verify($message, $signature);
|
||||
return $publicKey->verify(json_encode($message), $signature);
|
||||
}
|
||||
|
||||
public function testRequest()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue