| @@ 292-308 (lines=17) @@ | ||
| 289 | * @param string $path |
|
| 290 | * @return bool |
|
| 291 | */ |
|
| 292 | protected function encryptFile($path) { |
|
| 293 | ||
| 294 | $source = $path; |
|
| 295 | $target = $path . '.encrypted.' . time(); |
|
| 296 | ||
| 297 | try { |
|
| 298 | $this->rootView->copy($source, $target); |
|
| 299 | $this->rootView->rename($target, $source); |
|
| 300 | } catch (DecryptionFailedException $e) { |
|
| 301 | if ($this->rootView->file_exists($target)) { |
|
| 302 | $this->rootView->unlink($target); |
|
| 303 | } |
|
| 304 | return false; |
|
| 305 | } |
|
| 306 | ||
| 307 | return true; |
|
| 308 | } |
|
| 309 | ||
| 310 | /** |
|
| 311 | * output one-time encryption passwords |
|
| @@ 252-268 (lines=17) @@ | ||
| 249 | * @param string $path |
|
| 250 | * @return bool |
|
| 251 | */ |
|
| 252 | protected function decryptFile($path) { |
|
| 253 | ||
| 254 | $source = $path; |
|
| 255 | $target = $path . '.decrypted.' . $this->getTimestamp(); |
|
| 256 | ||
| 257 | try { |
|
| 258 | $this->rootView->copy($source, $target); |
|
| 259 | $this->rootView->rename($target, $source); |
|
| 260 | } catch (DecryptionFailedException $e) { |
|
| 261 | if ($this->rootView->file_exists($target)) { |
|
| 262 | $this->rootView->unlink($target); |
|
| 263 | } |
|
| 264 | return false; |
|
| 265 | } |
|
| 266 | ||
| 267 | return true; |
|
| 268 | } |
|
| 269 | ||
| 270 | /** |
|
| 271 | * get current timestamp |
|