Gpg4win – file encryption

This is a short note about using GnuPG on Windows 7/2008R2 to encrypt file(s) with symmetric AES encryption. GnuPG is installed on every Linux box that I work with. Fortunately, Windows port is well maintained and for simple batch use it’s enough to install Gpg4win-vanilla package from gpg4win.org. Current version Gpg4win 2.2.21 is shipping GnuPG 2.0.22.

Make sure that you have Gpg4win binaries in PATH (try to run gpg2), if they’re not then add to your path:

SET PATH=C:\Program Files (x86)\GNU\GnuPG;%PATH%

Here is an example of encrypting single file with gpg2:

cmd> gpg2 --batch --yes --passphrase mysecret -z 0 --cipher-algo AES128 --output "D:\TEMP\MYBACKUP.BAK.gpg" --symmetric "D:\ETL\MYBACKUP.BAK"

We’re telling gpg2 that we’re running command in batch mode (–batch), that we don’t want to compress data since input file is already compressed (-z 0) and that we wan’t to use AES128 encryption. With –output switch we’re telling gpg where to write encrypted file – this parameter always precedes command (–symmetric in this case), otherwise we get an error. In current version it’s not possible to specify wildcards for files, so encrypting single file is the only option with –symmetric command.

Decryption is as easy as:

cmd> gpg2 --batch --yes --passphrase mysecret --output "D:\ETL\MYBACKUP.BAK"  --decrypt "D:\TEMP\MYBACKUP.BAK.gpg"

Posted on 29.11.2013, in MS Windows and tagged , . Bookmark the permalink. Comments Off on Gpg4win – file encryption.

Comments are closed.