install phpseclib and create function to sign every body request

This commit is contained in:
Eduardo Bacarin 2025-06-13 16:25:04 -03:00
parent 37aab36cd9
commit be5a68f217
2 changed files with 9 additions and 5 deletions

View file

@ -16,5 +16,7 @@
"email": "me@bacarin.dev"
}
],
"require": {}
"require": {
"phpseclib/phpseclib": "~3.0"
}
}

View file

@ -2,17 +2,19 @@
namespace Kontrl\PhpKore;
use phpseclib3\Crypt\PublicKeyLoader;
class Kore
{
private $url = 'https://httpbin.org';
private $token;
public function __construct(){
$this->token = $this->auth();
}
public function auth(){
return '';
public function signBody(array $body, string|array $key, string|bool $password = false){
$publicKey = PublicKeyLoader::loadPrivateKey($key, $password);
return base64_encode($publicKey->sign(json_encode($body)));
}
public function testRequest(){