Note: You might want to consider using OpenSSL for file encryption instead. Please see this post.

In this post we will see how to use GnuPG to make a simple symmetric encryption and decryption. This method applies to encrypt a file so that it is unreadable.

GPG supports 11 cipher algorithms that you can use:

  • IDEA
  • 3DES
  • CAST5
  • BLOWFISH
  • AES
  • AES192
  • AES256
  • TWOFISH
  • CAMELLIA128
  • CAMELLIA192
  • CAMELLIA256

By default, GPG will use AES256 cipher for encryption. However, you can change the cipher algorithm by supplying --cipher-also CIPHER option.

To Encrypt:

$ gpg --output encrypted.data --symmetric --cipher-algo AES256 un_encrypted.data

To Decrypt:

$ gpg --output un_encrypted.data --decrypt encrypted.data

Note: You will be prompted for a password when encrypting or decrypt.