| Conditions | 1 |
| Paths | 1 |
| Total Lines | 12 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 1 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 32 | 1 | public function encrypt(string $plaintext): array |
|
| 33 | { |
||
| 34 | 1 | $key = $this->generateRandomBytes(16); |
|
| 35 | 1 | $ivLength = \openssl_cipher_iv_length($this->cipher); |
|
| 36 | 1 | $iv = $this->generateRandomBytes($ivLength); |
|
| 37 | 1 | $cipherText = \openssl_encrypt($plaintext, $this->cipher, $key, $this->options, $iv,$tag); |
|
| 38 | |||
| 39 | return [ |
||
| 40 | 1 | 'key' => \bin2hex($key), |
|
| 41 | 1 | 'iv' => \bin2hex($iv), |
|
| 42 | 1 | 'tag' => \bin2hex($tag), |
|
| 43 | 1 | 'ciphertext' => $cipherText, |
|
| 44 | ]; |
||
| 60 |