install phpseclib and create function to sign every body request
This commit is contained in:
parent
37aab36cd9
commit
be5a68f217
2 changed files with 9 additions and 5 deletions
|
@ -16,5 +16,7 @@
|
|||
"email": "me@bacarin.dev"
|
||||
}
|
||||
],
|
||||
"require": {}
|
||||
"require": {
|
||||
"phpseclib/phpseclib": "~3.0"
|
||||
}
|
||||
}
|
||||
|
|
10
src/Kore.php
10
src/Kore.php
|
@ -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(){
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue