0

I have encrypted a file using GPG and a passphrase as outlined in the Additional Notes of this StackOverflow response: https://stackoverflow.com/a/31552829/8304687

However, after trying to decrypt the file I can't see the decrypted contents. I can only see a string of garbled characters.

Here are the steps I took in a bash terminal on a Mac:

gpg --output file.txt --symmetric --cipher-algo AES256 file.txt

I was then curious and did cat file.txt assuming this would not change the file.

Then to decrypt it I did:

gpg --output new_file.txt --decrypt file.txt

and got the following messages in the Terminal:

gpg: AES256.CFB encrypted data
gpg: encrypted with 1 passphrase

When I try to view my decrypted file with cat new_file.txt the output is a string of garbled characters.

What have I done wrong and how can I see the contents of my encrypted file?

  • Unless we see your particular code we will not be able to see where your error might be. – rossum Apr 17 '21 at 10:41
  • The code is written in the post above. It was all done on the CLI, I didn't use a script. Is there something I'm missing? – JenniferHL3 Apr 17 '21 at 13:50
  • When you decrypt you do not enter a decryption key. If you encrypted with a key then you need the same key to decrypt. Have a check on how your system handles keys. – rossum Apr 17 '21 at 17:07

1 Answers1

0

I've just tested and the problem comes from giving the encrypted file the same name as the file to encrypt.

This works:

gpg --output file.txt.gpg --symmetric --cipher-algo AES256 file.txt

But not this:

gpg --output same_name.txt --symmetric --cipher-algo AES256 same_name.txt

Does anyone know if there is a way to decrypt after having given the encrypted file the same name?