| @@ 39-51 (lines=13) @@ | ||
| 36 | * |
|
| 37 | * @return string |
|
| 38 | */ |
|
| 39 | protected static function opensslEncrypt( |
|
| 40 | string $data, |
|
| 41 | string $cipher, |
|
| 42 | string $key, |
|
| 43 | string $iv, |
|
| 44 | string &$tag |
|
| 45 | ): string { |
|
| 46 | if (OpensslStatic::tagRequired($cipher)) { |
|
| 47 | return \openssl_encrypt($data, $cipher, $key, 1, $iv, $tag, '', 4); |
|
| 48 | } else { |
|
| 49 | return \openssl_encrypt($data, $cipher, $key, 1, $iv); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * OpenSSL decrypt wrapper function |
|
| @@ 64-76 (lines=13) @@ | ||
| 61 | * |
|
| 62 | * @return string |
|
| 63 | */ |
|
| 64 | protected static function opensslDecrypt( |
|
| 65 | string $input, |
|
| 66 | string $cipher, |
|
| 67 | string $key, |
|
| 68 | string $iv, |
|
| 69 | string $tag |
|
| 70 | ): string { |
|
| 71 | if (OpensslStatic::tagRequired($cipher)) { |
|
| 72 | return \openssl_decrypt($input, $cipher, $key, 1, $iv, $tag, ''); |
|
| 73 | } else { |
|
| 74 | return \openssl_decrypt($input, $cipher, $key, 1, $iv); |
|
| 75 | } |
|
| 76 | } |
|
| 77 | ||
| 78 | /** |
|
| 79 | * Get IV size for specified CIPHER. |
|