Automated Decryption problem

Hi All,

I receive a PGP file daily. I am able to decrypt this no problem by copying the contents to the GNU Clipboard and then Decrypting.

The problem is that when I right-click the pgp file and select decrypt, the file does decrypt but the format is off. The words, numbers all lose their spacing making the decrypted file useless.

Any ideas what may be causing this?

Hi Aaron,

by your description, I assume that you try to decrypt some kind of comma, tab or space separated file? Could you please elaborate which Windows version you have and which gpg4win version you use, when you decrypt. And, if the information is available to you, which software the provider of the encrypted file uses?

Kind regards,

Hi, Thank you for the reply,

The Version of gpg4win ; 2.3.0
Windows OS: Server 2008 r2

Yes the file is I believe tab or comma separated but cant be 100% sure. I have contacted the other party to find out what encryption software they use.

My ultimate goal is to have a script that will decrypt these files daily, the script is working fine but the result is a decrypted .txt file that has not held its format.

It is strange that manually copying the text to clipboard and decrypting results are perfect. very frustrating.

Thanks again.

It seems, that the opposite party uses not a file encryption, but a text encryption, otherwise the file itself would be encrypted, not the containing text. Nonetheless you should be able to automate the process. How did you try to decrypt the mail automatically until now? Have you already tried “gpg --output unencrypted.txt --decrypt encrypted.txt”.

Kind regards

Below is this script I use. This works perfectly except the spacing between words/fields in the decrypted text is all off

::Decrypt File

echo ‘Password’|gpg --keyring “C:\Keyring” --secret-keyring “C:\Keyring\secret-key-BCFAE871.asc” --batch --yes --passphrase-fd 0 -o E:\code\interface\Barclays\Live\in\Decrypted\Decrypted_%date:~-4,4%-%date:~-7,2%-%date:~-10,2%.txt -d E:\code\interface\Barclays\Live\in*.PGP

Also, I asked the party encrypting the files what program they use and this is the response they gave;

‘There’s no specific version of PGP required for the VFDS service, we simply ask each client to provide us with their public PGP key and we encrypt the files using that. This ensures that the files are ultimately only readable by the holder of the corresponding private key’

Is there something I am doing wrong? live I said before, manually pasting the encrypted text into the GPU clipboard and then decrypting works fine, the text layout is as expected. Its only when I automate the process I have an issue.

thanks again for all the help. This is really causing us issues as we get an encrypted file everyday, and that needs to be decrypted everyday.

Hi Aaron,

I Assume, that the other Party uses a Linux based Newline and this can’t be interpreted by some editors ( Try another editor (like and switch between the newline options.

Thanks, that works when I change to UNIX. Any idea how I would get my txt documents to save in that format?

Hi Aaron,
many editors have the build in capabilites to transform line endings.
Then of course there a many small helper applications to do this in batch files.

You could also try gnupg2 --textmode option.
(This is what the encryption party should have used, ideally.)

ps.: If you like Gpg4win and the answers provider here, consider supporting
us financially at