Wednesday, September 10, 2014

How to Encrypt And Decrypt Files with GPG?

Linux: How To Encrypt And Decrypt Files With A Password in gpg?


T

o encrypt and decrypt files with a password,  you canuse gpg command. This is an encryption  tool for Linux/UNIX like operating system.

gnupg

GnuPG stands for GNU Privacy Guard.

Encrypting a file in linux

To encrypt a single file, 
$ gpg -c somefilename
It will prompt for password:
Enter passphrase:
Repeat passphrase:
This will create a somefilename.gpg file. Where,
  • -c : Encrypt with symmetric cipher using a passphrase. The default symmetric cipher used is CAST5, but may be chosen with the --cipher-algo option. This option may be combined with --sign (for a signed and symmetrically encrypted message), --encrypt (for a message that may be decrypted via a secret key or a passphrase), or --sign and --encrypt together (for a signed message that may be decrypted via a secret key or a passphrase).
Note that if you ever forgot your password (passphrase), you cannot recover the data as it use very strong encryption.

How to Decrypt a file

To decrypt file use the gpg command as follow:
$ gpg somefilename.gpg
gpg: CAST5 encrypted data
Enter passphrase:

No comments:

Post a Comment