1 | <?php |
||
20 | class Mcrypt extends Abstraction implements Executable |
||
21 | { |
||
22 | use OptionMasker; |
||
23 | |||
24 | /** |
||
25 | * Key to pass via cli |
||
26 | * |
||
27 | * @var string |
||
28 | */ |
||
29 | private $key; |
||
30 | |||
31 | /** |
||
32 | * Key file |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | private $keyFile; |
||
37 | |||
38 | /** |
||
39 | * Algorithm to use |
||
40 | * |
||
41 | * @var string |
||
42 | */ |
||
43 | private $algorithm; |
||
44 | |||
45 | /** |
||
46 | * Hash to use |
||
47 | * |
||
48 | * @var string |
||
49 | */ |
||
50 | private $hash; |
||
51 | |||
52 | /** |
||
53 | * Path to config file |
||
54 | * |
||
55 | * @var string |
||
56 | */ |
||
57 | private $config; |
||
58 | |||
59 | /** |
||
60 | * Keep the not encrypted file |
||
61 | * |
||
62 | * @var boolean |
||
63 | */ |
||
64 | private $deleteUncrypted = true; |
||
65 | |||
66 | /** |
||
67 | * Path to the encrypted file |
||
68 | * |
||
69 | * @var string |
||
70 | */ |
||
71 | private $targetFile; |
||
72 | |||
73 | /** |
||
74 | * Constructor. |
||
75 | * |
||
76 | 8 | * @param string $path |
|
77 | */ |
||
78 | 8 | public function __construct(string $path = '') |
|
79 | 8 | { |
|
80 | 8 | $this->setup('mcrypt', $path); |
|
81 | $this->setMaskCandidates(['key']); |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * Set the target file. |
||
86 | * |
||
87 | * @param string $path |
||
88 | 7 | * @return \phpbu\App\Cli\Executable\Mcrypt |
|
89 | */ |
||
90 | 7 | public function saveAt(string $path) : Mcrypt |
|
95 | |||
96 | /** |
||
97 | * Delete the uncrypted data. |
||
98 | * |
||
99 | * @param bool $bool |
||
100 | 2 | * @return \phpbu\App\Cli\Executable\Mcrypt |
|
101 | */ |
||
102 | 2 | public function deleteUncrypted(bool $bool) : Mcrypt |
|
107 | |||
108 | /** |
||
109 | * Key to use for encryption. |
||
110 | * |
||
111 | * @param string $key |
||
112 | 5 | * @return \phpbu\App\Cli\Executable\Mcrypt |
|
113 | */ |
||
114 | 5 | public function useKey(string $key) : Mcrypt |
|
119 | |||
120 | /** |
||
121 | * Key file to use for encryption. |
||
122 | * |
||
123 | * @param string $keyFile |
||
124 | 3 | * @return \phpbu\App\Cli\Executable\Mcrypt |
|
125 | */ |
||
126 | 3 | public function useKeyFile(string $keyFile) : Mcrypt |
|
131 | |||
132 | /** |
||
133 | * Set algorithm to use. |
||
134 | * |
||
135 | * @param string $algorithm |
||
136 | 8 | * @return \phpbu\App\Cli\Executable\Mcrypt |
|
137 | */ |
||
138 | 8 | public function useAlgorithm(string $algorithm) : Mcrypt |
|
143 | |||
144 | /** |
||
145 | * Hash to use for encryption. |
||
146 | * |
||
147 | * @param string $hash |
||
148 | 5 | * @return \phpbu\App\Cli\Executable\Mcrypt |
|
149 | */ |
||
150 | 5 | public function useHash(string $hash) : Mcrypt |
|
155 | |||
156 | /** |
||
157 | * Set path to sync to. |
||
158 | * |
||
159 | * @param string $path |
||
160 | 3 | * @return \phpbu\App\Cli\Executable\Mcrypt |
|
161 | */ |
||
162 | 3 | public function useConfig(string $path) : Mcrypt |
|
167 | |||
168 | /** |
||
169 | * Mcrypt CommandLine generator. |
||
170 | * |
||
171 | * @return \SebastianFeldmann\Cli\CommandLine |
||
172 | 8 | * @throws \phpbu\App\Exception |
|
173 | */ |
||
174 | 8 | protected function createCommandLine() : CommandLine |
|
197 | } |
||
198 |