Symmetric File Encryption with GnuPG
  • 28th Aug 2022 •
  •  1 min read

To encrypt/decrypt a file with a password, we can use GnuPG (gpg) with the symmetric flag.

For encrypting file test:

gpg --no-symkey-cache --symmetric --cipher-algo AES256 test

  • no-symkey-cache to force gpg not to cache the password.
  • We choose AES-256 as the cipher algorithm.

You will be prompted for a password and if everything goes well, the encrypted file test.gpg will be output.

To decrypt the same file:

gpg --no-symkey-cache --decrypt test.gpg

This will output in stdin. If you want to output to a file use the -o <file> flag.