| Conditions | 2 |
| Paths | 2 |
| Total Lines | 12 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php declare(strict_types=1); |
||
| 49 | public function encrypt(string $request, string $nonce = null) |
||
| 50 | { |
||
| 51 | $this->nonce = $nonce ?? \random_bytes(SODIUM_CRYPTO_BOX_NONCEBYTES); |
||
| 52 | |||
| 53 | try { |
||
| 54 | return \sodium_crypto_box( |
||
| 55 | $request, |
||
| 56 | $this->nonce, |
||
| 57 | $this->keypair |
||
| 58 | ); |
||
| 59 | } catch (SodiumException $e) { |
||
| 60 | throw new InvalidArgumentException($e->getMessage()); |
||
| 61 | } |
||
| 92 | } |