/**
* @param \File $file
* @param null|Key $key
* @return bool|\File
* @throws InvalidInput
* @throws CryptoException
*/
public function decryptFile($file, $key = null)
{
$key = $this->getKey($key);
$decryptedFilename = str_replace('.enc', '', $file->getFullPath());
try {
File::decryptFile($file->getFullPath(), $decryptedFilename, $key);
unlink($file->getFullPath());
$file->Filename = str_replace('.enc', '', $file->Filename);
$file->Name = str_replace('.enc', '', $file->Name);
$file->write();
return $file;
} catch (Exception $e) {
SS_Log::log(sprintf('Decryption exception while parsing "%s": %s', $file->Name, $e->getMessage()), SS_Log::ERR);
return false;
}
}