1 | <?php |
||
17 | class OpensslWrapper |
||
18 | { |
||
19 | |||
20 | /** |
||
21 | * OpenSSL encrypt wrapper function |
||
22 | * |
||
23 | * @param string $data Data to decrypt |
||
24 | * @param string $method Cipher method to use |
||
25 | * @param string $key Key string |
||
26 | * @param string $iv Initialization vector |
||
27 | * @return string |
||
28 | */ |
||
29 | public static function encrypt(string $data, string $method, string $key, string $iv): string |
||
35 | |||
36 | /** |
||
37 | * OpenSSL decrypt wrapper function |
||
38 | * |
||
39 | * @param string $data Data to decrypt |
||
40 | * @param string $method Cipher method to use |
||
41 | * @param string $key Key string |
||
42 | * @param string $iv Initialization vector |
||
43 | * @return string |
||
44 | */ |
||
45 | public static function decrypt(string $data, string $method, string $key, string $iv): string |
||
51 | |||
52 | /** |
||
53 | * Throw an exception if openssl function returns false |
||
54 | * |
||
55 | * @param string|bool $data |
||
56 | * @return string |
||
57 | * @throws \Exception |
||
58 | */ |
||
59 | private static function returnOrException($data): string |
||
67 | } |
||
68 |