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