1 | <?php |
||
21 | class AesEncrypter |
||
22 | { |
||
23 | const STRATEGY_OPENSSL = 'openssl'; |
||
24 | const STRATEGY_MCRYPT = 'mcrypt'; |
||
25 | |||
26 | /** |
||
27 | * @var AesEncryptionStrategy |
||
28 | */ |
||
29 | private $strategy; |
||
30 | |||
31 | /** |
||
32 | * Constructor |
||
33 | * |
||
34 | * @param string $key The secret key |
||
35 | * @param string $method |
||
36 | * @param AesEncryptionStrategy $strategy |
||
37 | */ |
||
38 | public function __construct($key, $method = AesEnum::METHOD_256, $strategy = null) |
||
53 | |||
54 | /** |
||
55 | * Encrypts any data using mac-then-encrypt method |
||
56 | * |
||
57 | * @param mixed $data |
||
58 | * @return string |
||
59 | */ |
||
60 | public function encrypt($data) |
||
70 | |||
71 | /** |
||
72 | * Decrypts data encrypted through encrypt() method |
||
73 | * |
||
74 | * @param string $data |
||
75 | * @return mixed |
||
76 | * @throws IvSizeMismatchException If the IV length has been altered |
||
77 | * @throws MacHashMismatchException If the data has been altered |
||
78 | */ |
||
79 | public function decrypt($data) |
||
97 | } |
||
98 |