4

I have Windows 7. (Not Windows 10 so I don't have the fancy native "Windows Services for Unix" that Windows 10 apparently has)

How do you use gpg4win from command line to encrypt or decrypt a file?

I saw a video on youtube that mentioned that on linux you can do gpg -c blah.txt then enter a password when prompted, and it encrypts the file, and gpg blah.gpg to decrypt it.

I ran gpg4win and it installs this thing called Kleopatra which is a GUI program and has a button for encrypt and a button for decrypt, and for encryption I untick "sign as" and tick "encrypt with password", and that encryption works, and decryption works.

But I want to be able to do it from command line too.

I looked where gpg4win installed, and I can't see a gpg.exe

C:\Program Files (x86)\Gpg4win\bin>dir gpg*
 Volume in drive C has no label.
 Volume Serial Number is 4645-5DCE

Directory of C:\Program Files (x86)\Gpg4win\bin

04/09/2020 13:37 34,304 gpg-error.exe 04/09/2020 13:46 398,848 gpgex.dll 04/09/2020 13:47 77,824 gpgme-json.exe 04/09/2020 13:47 16,896 gpgme-w32spawn.exe 04/09/2020 13:50 2,632,704 gpgol.dll 04/09/2020 13:52 260,608 gpgolconfig.exe 04/09/2020 13:52 244,736 gpgolkeyadder.exe 7 File(s) 3,665,920 bytes 0 Dir(s) 34,931,535,872 bytes free

C:\Program Files (x86)\Gpg4win\bin>


Update

The problem has solved itself!

Not sure whether to post this as an answer as it's all a bit strange.. why wasn't gpg.exe there, why did it suddenly appear.

This doesn't make much sense to me but I just opened cygwin, which I haven't tried installing gpg in.. and I found the gpg command worked(though I had to do ctrl-c when running it from cygwin but it worked). I did which gpg and it showed /cygdrive/c/Program Files (x86)/GnuPG/bin/gpg

I then opened a regular cmd prompt

C:\Program Files (x86)\GnuPG\bin>dir gpg*
 Volume in drive C has no label.
 Volume Serial Number is 4645-5DCE

Directory of C:\Program Files (x86)\GnuPG\bin

03/09/2020 15:39 399,008 gpg-agent.exe 03/09/2020 15:39 171,680 gpg-connect-agent.exe 03/09/2020 15:39 84,128 gpg-preset-passphrase.exe 03/09/2020 15:39 216,736 gpg-wks-client.exe 03/09/2020 15:39 1,088,160 gpg.exe 03/09/2020 15:39 150,176 gpgconf.exe 03/09/2020 15:39 24,224 gpgme-w32spawn.exe 03/09/2020 15:39 496,800 gpgsm.exe 03/09/2020 15:39 158,880 gpgtar.exe 03/09/2020 15:39 514,208 gpgv.exe 10 File(s) 3,304,000 bytes 0 Dir(s) 34,930,319,360 bytes free

C:\Program Files (x86)\GnuPG\bin>

gpg.exe has "magically" appeared and the date of the files (which is in the UK form dd/mm/yyyy)

C:\Users\User>date
The current date is: 20/11/2020
Enter the new date: (dd-mm-yy)
C:\Users\User>

The date of the files has shifted from 4th september 2020(see directory listing in my question), to 3rd september 2020.. All within 5 minutes.

So it works , and works well and properly , from cmd.exe and I see gpg.exe listed now. But it wasn't there before!

C:\Users\User\bbb>gpg -c a.txt_pwd_a
File 'a.txt_pwd_a.gpg' exists. Overwrite? (y/N) y

C:\Users\User\bbb>gpg a.txt_pwd_a.gpg gpg: WARNING: no command supplied. Trying to guess what you mean ... gpg: AES.CFB encrypted data gpg: encrypted with 1 passphrase File 'a.txt_pwd_a' exists. Overwrite? (y/N) y

C:\Users\User\bbb>

barlop
  • 25,198

1 Answers1

5

It's two different folders that are similar in name - Gpg4win vs. GnuPG.

The first path is: C:\Program Files (x86)\Gpg4win\bin

The second path, where gpg.exe is located, is: C:\Program Files (x86)\GnuPG\bin

I didn't notice this at first myself when trying to find gpg.exe.

jah
  • 66