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"
|
"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;
|
namespace Kontrl\PhpKore;
|
||||||
|
|
||||||
|
use phpseclib3\Crypt\PublicKeyLoader;
|
||||||
|
|
||||||
class Kore
|
class Kore
|
||||||
{
|
{
|
||||||
private $url = 'https://httpbin.org';
|
private $url = 'https://httpbin.org';
|
||||||
private $token;
|
|
||||||
|
|
||||||
public function __construct(){
|
public function __construct(){
|
||||||
$this->token = $this->auth();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function auth(){
|
public function signBody(array $body, string|array $key, string|bool $password = false){
|
||||||
return '';
|
$publicKey = PublicKeyLoader::loadPrivateKey($key, $password);
|
||||||
|
return base64_encode($publicKey->sign(json_encode($body)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRequest(){
|
public function testRequest(){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue