| Conditions | 2 |
| Paths | 2 |
| Total Lines | 14 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | public function create(string $message, string $nonce_bin = null):CryptoBoxInterface{ |
||
| 18 | $this->checkKeypair(SODIUM_CRYPTO_BOX_SECRETKEYBYTES); |
||
| 19 | |||
| 20 | $message = $this->checkMessage($message); |
||
| 21 | $this->nonce = $nonce_bin ?? random_bytes(SODIUM_CRYPTO_BOX_NONCEBYTES); |
||
| 22 | $this->box = sodium_crypto_secretbox($message, $this->nonce, $this->keypair->secret); |
||
|
|
|||
| 23 | |||
| 24 | sodium_memzero($message); |
||
| 25 | |||
| 26 | if($nonce_bin !== null){ |
||
| 27 | sodium_memzero($nonce_bin); |
||
| 28 | } |
||
| 29 | |||
| 30 | return $this; |
||
| 31 | } |
||
| 46 |