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
16.83k stars 492 forks source link

UX: Empty files created upon passphrase mismatch #159

Closed jynik closed 3 years ago

jynik commented 3 years ago

What were you trying to do

Create an encrypted file using a symmetric key.

What happened

When a passphrase is entered incorrectly, an empty output file is created. My expectation was that no file would be created until after the program has performed the encryption operation.

$ echo "Hello World" > test.txt
$ age -p -o test.txt.age test.txt
Enter passphrase (leave empty to autogenerate a secure one):  Test
Confirm passphrase: test
Error: passphrases didn't match
[ Did age not do what you expected? Could an error be more useful? Tell us: https://filippo.io/age/report ]
$ ls -l
-rw-r--r-- 1 user user   12 Nov 29 13:31 test.txt
-rw-r--r-- 1 user user    0 Nov 29 13:32 test.txt.age