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