-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAsymCrypter.php
47 lines (37 loc) · 1 KB
/
AsymCrypter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
namespace rogoss\OSSL;
class AsymCrypter
{
protected ?\Closure $hJSON = null;
protected string $sKey = "";
protected string $sCryptFunction = "";
protected function __construct(
private string $sPublicKeyFunction,
private string $sPrivateKeyFunction,
private \Closure $hJSONHandler
) {
$this->sCryptFunction = $this->sPublicKeyFunction;
$this->hJSON = fn($i) => $i;
}
final public function publicKey(string $sKey): static
{
$this->sKey = $sKey;
$this->sCryptFunction = $this->sPublicKeyFunction;
return $this;
}
final public function privateKey(string $sKey): static
{
$this->sKey = $sKey;
$this->sCryptFunction = $this->sPrivateKeyFunction;
return $this;
}
/**
* Enable this, if you want to en-/decrypt Arrays or objects
* @return
*/
public function json(): static
{
$this->hJSON = $this->hJSONHandler;
return $this;
}
}