1 | <?php |
||
30 | class OpensslStack |
||
31 | { |
||
32 | /** |
||
33 | * Stack of cipher/algo combos. |
||
34 | * |
||
35 | * @var array |
||
36 | */ |
||
37 | private $_stack = []; |
||
38 | |||
39 | /** |
||
40 | * High entropy key. |
||
41 | * |
||
42 | * @var string |
||
43 | */ |
||
44 | private $_key; |
||
45 | |||
46 | /** |
||
47 | * OpensslStack constructor. |
||
48 | * |
||
49 | * @param string $key Password or key |
||
50 | */ |
||
51 | 2 | public function __construct(string $key) |
|
55 | |||
56 | /** |
||
57 | * Add a new cipher/algo combo to the execution stack. |
||
58 | * |
||
59 | * @param string $cipher Cipher mode to use |
||
60 | * @param string $algo Hashing algo to use |
||
61 | * |
||
62 | * @return OpensslStack |
||
63 | */ |
||
64 | 2 | public function add(string $cipher, string $algo): self |
|
70 | |||
71 | /** |
||
72 | * Encrypt data using custom stack. |
||
73 | * |
||
74 | * @param string $data Data to encrypt |
||
75 | * |
||
76 | * @return string |
||
77 | */ |
||
78 | 2 | public function encrypt(string $data): string |
|
86 | |||
87 | /** |
||
88 | * Decrypt data using custom stack. |
||
89 | * |
||
90 | * @param string $data Data to decrypt |
||
91 | * |
||
92 | * @return string |
||
93 | */ |
||
94 | 2 | public function decrypt(string $data): string |
|
102 | } |
||
103 |