Easy File Encryption On Ubuntu Linux with OpenSSL

Here’s an easy way to encrypt your file using OpenSSL. The general syntax is:


openssl enc (cipher) -e -in (input file) -out (output file)

so to encrypt a “plaintext.txt” file, using aes256, you only need to run this command:

openssl enc aes256 -e -in plaintext.txt -out encrypted.txt

Similarly, to decrypt the file, you can run the command:

openssl enc aes256 -d -in encrypted.txt -out decrypted.txt

How to use GNU Privacy Guard (GPG) – Encrypt, Decrypt, Sign and Verifying identities

GPG or the GNU Privacy Guard is a free and open source software that implements OpenPGP public-key cryptography message format (RFC4880). You can use GPG to encrypt, decrypt, sign and verify files or emails. To use GPG, you need to generate the public-key/private-key pairs in your computer by running this command, and choose the default option


gpg --gen-key

The application will ask you to enter your ID and passphrase, make sure you choose a strong passphrase to guarantee the safety and security of your keys.

Encrypting and Decrypting Files
You can use GPG to encrypt files, it can be only decrypted by those who have your public-key. The command that can be used to encrypt file is :

gpg --out encrypted_file.txt --encrypt original_file.txt

Run this command to decrypt. Files encrypted with private key can only be decrypted with public key and vice-versa.

gpg --out decrypted.txt --decrypt encrypted_file.txt

Signing Email or body of texts
Alternatively, you can chose to sign emails/texts instead of encrypting them. Signing files is a way to ensure that the message/texts/emails are from the right sender and its content has not been tempered with. You can run this command to sign email or texts :

gpg --clearsign original_text.txt

This will produce a signature file which content the original text with PGP signature embedded at the bottom of the message.

To verify it (assuming you have the public key), you need to run this command:

gpg --verify original_text.txt.asc

Continue reading “How to use GNU Privacy Guard (GPG) – Encrypt, Decrypt, Sign and Verifying identities”