@@ 206-220 (lines=15) @@ | ||
203 | * |
|
204 | * @return void |
|
205 | */ |
|
206 | protected function encryptFile($source_file, $target_file, $iv) |
|
207 | { |
|
208 | // We start by setting up both the source and target streams |
|
209 | // and applying all the necessary stream filters for encryption. |
|
210 | ||
211 | $source = fopen($source_file, 'r'); |
|
212 | $target = $this->createEncryptionStream($target_file, $this->getOptions($iv)); |
|
213 | ||
214 | // We copy the source into the target stream, passing through the encryption filter |
|
215 | $this->copyStream($source, $target); |
|
216 | ||
217 | // Close the source file and target files |
|
218 | fclose($source); |
|
219 | fclose($target); |
|
220 | } |
|
221 | ||
222 | /** |
|
223 | * Decrypts a source file into a target file |
|
@@ 232-244 (lines=13) @@ | ||
229 | * |
|
230 | * @return void |
|
231 | */ |
|
232 | protected function decryptFile($source, $target, $iv, $padding = 0) |
|
233 | { |
|
234 | // We create a stream with a decryption filter appended to it |
|
235 | $source = $this->createDecryptionStream($source, $this->getOptions($iv)); |
|
236 | $target = fopen($target, 'w+'); |
|
237 | ||
238 | // We copy the source into the target, decrypting it in the process |
|
239 | $this->copyStream($source, $target, $padding); |
|
240 | ||
241 | // Close both source and target |
|
242 | fclose($source); |
|
243 | fclose($target); |
|
244 | } |
|
245 | ||
246 | /** |
|
247 | * Creates a stream that encrypts when written to |