13

I used to download files and then use openssl to encrypt them, which is not enough for me. How can I encrypt the download gradually as the file is being downloaded?

I thought about using curl and an openssl pipe but cannot figure it out.

Is there any better tool to perform this?

Mark Kirby
  • 18,949
  • 19
  • 79
  • 116
user123456
  • 2,478

3 Answers3

30

The command would simply be:

curl -s "$URL" | openssl aes-256-cbc > "$OUTPUT_FILE"
heemayl
  • 93,925
user123456
  • 2,478
12

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.

Bruni
  • 11,099
6

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.