. */ declare(strict_types=1); namespace FireflyIII\Services\Internal\File; use FireflyIII\Exceptions\FireflyException; /** * Class EncryptService */ class EncryptService { /** * @param string $file * @param string $key * * @throws FireflyException */ public function encrypt(string $file, string $key): void { if (!file_exists($file)) { throw new FireflyException(sprintf('File "%s" does not seem to exist.', $file)); } $content = file_get_contents($file); $content = Crypt::encrypt($content); $newName = sprintf('%s.upload', $key); $path = storage_path('upload') . '/' . $newName; file_put_contents($path, $content); } }