Want to decrypt a file yet gpg says encrypting

Hello, I somewhat new to encryption, and I am new to this forum too.

I am using gpg (GnuPG) 2.4.4, on Linux Mint 22 and I really love it.

I have created a bash script (that seems to be working fine) to decrypt a file, run a spreadsheet, then encrypt the file again. In the script I must delete the old encrypted file before encrypting it again. After encrypting, I delete the plain file.

I am using gpg with the following 2 lines …

to decrypt

gpg -d --passphrase {my_passwd} --batch -o plain_file_name encrypted_file_name

and…

to encrypt

gpg --symmetric --passphrase {my_passwd} --batch -o encrypted_file_name plain_file_name

When DEcrypting the file, gpg responds with…

Attempting to decrypt the file…
gpg: AES256.CFB encrypted data
gpg: encrypted with 1 passphrase

note it says encrypted not decrypted.

When ENcrypting the file, I get no response at all.

I also note in the help screen “gpg –help” I see the line “-d, --decrypt decrypt data (default)” yet I see I did not put the -e in the encryption line but it still encrypts. so I am confused.

I can put the verbose flag (-v) in the encryption line, but that doesn’t tell me if it is encrypted or decrypted.

#1, how do I get gpg to show me what it is doing during the ENcryption process?

#2, why does it say ENcrypting when it is actually DEcrypting?

#3, why is it ENcrypting the file even thou I didn’t put the -e and the default is to DEcrypt?

Thanks for your help, Mark.

It wants to say “The input file is encrypted with 1 passphrase”. It does not say “Encrypting with 1 passphrase”.

You use --batch, which does not produce output when there are no errors. Best check the exit code. It should be 0 for success.

In batch mode, check the exit code to verify that the operation succeeded.

Hello swagner:

Thank you for your input.

I copied and pasted the output from my script and I bit off too much. I see I included an line echo’d from my bash script.

The "Attempting to decrypt the file…” is me echoing a progress indicator in my script. Sorry for that, my bad.

I guess I can understand the 2 lines output from gpg, It is telling me how it was encrypted, not what it is doing.

I took your advice and added checking the result code from gpg and added an error handler. Thanks for the tip.

As for the --batch part. I am using that in both the encrypting and decrypting, yet getting differing results.

I just added a -q (quiet) to the decrypting line so the output from my scripts are not polluted

Thank you again.

Mark.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.