How can I gradually encrypt a file that is being downloaded?
Solution 1:
The command would simply be:
curl -s "$URL" | openssl aes-256-cbc > "$OUTPUT_FILE"
Solution 2:
I do not think that this is possible (It seems I have been proven wrong on this).
However, provided the reason this is not enough for you, is that you don't want an unencrypted version of the file being stored on your drive (and potentially being restored by somebody in the future) you could use a ramdisk to temporarily store the file and encrypt it there before moving it to its destination directory.
Depending on your paranoia level and thread scenario, simply using an encrypted drive would suffice.
Solution 3:
You can also use a mountable, filesystem-level encrypted filesystem, as EncFS or CryFS. Mount your encrypted directory and download files there. Not sure if this solves your problem, as it is not clear to me what exactly your problem is.