In this guide, you’ll learn how to encrypt a file using symmetric encryption.
1. Install GnuPG
First, you need to install GnuPG on your operating system. GnuPG, or GPG as it’s often called, is a free software program based on the PGP encryption standard that allows users to encrypt, sign data, and even manage keys.
- Linux: Open a terminal window and run the command
sudo apt-get install gnupg2
- Windows: Download GnuPG from the GNU Privacy Guard for Windows website and install it.
- macOS: Open a terminal window and run the command brew install gpg (if the command doesn’t work, you probably need first to install Homebrew).
2. Encrypt your file
Open a terminal window to run the following command. Replace “filename.txt” with the file’s full name you want to encrypt. You will be prompted to use a password.
- Windows:
gpg -c -a --cipher-algo AES256 filename.txt
- macOS, Linux:
gpg2 -c -a --cipher-algo AES256 filename.txt
3. Decrypt your file
The following command will decrypt the file. Remember to replace “filename” with the name of your encrypted file.
- Windows:
gpg -d -a filename.txt.asc
- macOS, Linux:
gpg2 -d -a filename.txt.gpg
The file’s content will display in the terminal.
To output the content to a file, add the –output flag
- macOS, Linux:
gpg2 -d -a --output decryptedfilename filename.txt.gpg










