Alpha Hydrae

Coding on the edge of the web...

Symmetric Encryption With GnuPG 2

I use these commands to symmetrically encrypt files with GnuPG 2. Sometimes you just need to get away from all this private/public key business.

Install gnupg2 with your favorite package manager, then type the following commands. It will prompt for the encryption password:

1
2
3
4
5
# encrypt file.txt to file.txt.gpg
gpg2 -c -a --force-mdc --batch -o file.txt.gpg file.txt

# decrypt file.txt.gpg to file.txt
gpg2 -d --batch -o file.txt file.txt.gpg

If you want to get the password from a file, use these:

1
2
3
4
5
# encrypt file.txt to file.txt.gpg
gpg2 -c -a --force-mdc --batch --passphrase-file passphrase.txt -o file.txt.gpg file.txt

# decrypt file.txt.gpg to file.txt
gpg2 -d --batch --passphrase-file passphrase.txt -o file.txt file.txt.gpg

May your files be secure.

Comments