Symmetric file encryption and decryption using GnuPG

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
  • AES
  • AES192
  • AES256

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 --symmetric --cipher-algo AES256

To Decrypt:

$ gpg --output --decrypt

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

Hazmirul Afiq

Read more posts by this author.