In my webapp, users can upload files. Before being saved and stored, the contents of the file are encrypted using something like this:
Crypt::encrypt(file_get_co
Laravel 5.6 allows you to use streams for downloads: https://laravel.com/docs/5.6/responses#file-downloads
So in your case:
return $response()->streamDownload(function() use $decryptedContents { echo $decryptedContents; }, $fileName);