0

I'm gpg encrypting text files that contain fixed-character length lines of data. The client requires the ends of each line have a specific amount of trailing whitespace. When I gpg encrypt the files, that whitespace is removed.

How can I preserve the trailing whitespace on each line?

gpg (GnuPG) 2.2.4
libgcrypt 1.8.1

gpg --batch --encrypt --quiet --yes --always-trust -r keyname filename

pmilkman
  • 33
  • 3

1 Answers1

1

I can't reproduce this behavior. Here's an example text file; it looks like this:

this                                   
is                                     
a                                      
test                                   

Each line is 40 characters long (some text the beginning and then space-padded out to 40 characters). Here's a base64 version of the same file in case the above doesn't copy and paste correctly:

dGhpcyAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCmlzICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgIAphICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAKdGVzdCAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCg==

If I encrypt this file:

gpg --batch --encrypt --quiet --yes --always-trust -r testuser@example.com example.txt

And then decrypt the file:

gpg < example.txt.gpg > example.dec

I have the same file that I started with:

$ sha256sum example.txt example.dec
271db32972e3af0fa0c787b67f8f00fe7a97523f0669f5676e766eba281f0883  example.txt
271db32972e3af0fa0c787b67f8f00fe7a97523f0669f5676e766eba281f0883  example.dec

The whitespace has been preserved on all lines.

larsks
  • 43,623
  • 14
  • 121
  • 180
  • Going to mark this as the answer, thanks for the response! Although the issue turned out to be incorrect feedback from the client who was complaining about the trailing spaces. Unclear what they did to fix it on their end, but this isn't an issue anymore for us. – pmilkman Sep 26 '22 at 16:06