FiloSottile / age

A simple, modern and secure encryption tool (and Go library) with small explicit keys, no config options, and UNIX-style composability.
https://age-encryption.org
BSD 3-Clause "New" or "Revised" License
15.75k stars 475 forks source link

Decryption does not create a file when data is empty #555

Closed kautsig closed 2 weeks ago

kautsig commented 3 months ago

Environment

What were you trying to do

Using age in a script to automatically en-/decrypt files in a batch process.

What happened

I can encrypt an empty file, but decryption does not re-create the input.

$ age-keygen -o key.txt
$ echo -n "" | age -r age1xe9fdxsrj6025yxl2yzlpalpmn2yypt3a7ysk4c2hpncq2nt9als8wh7hg > data.age
$ age --decrypt -i key.txt -o empty-file data.age 
$ cat empty-file
cat: empty-file: No such file or directory

This is a problem in scripts, because i have to handle this case specifically. I appended a && touch empty-file as a work around. Still, the behavior was very unexpected.

FiloSottile commented 2 weeks ago

Thank you for the report!