How to use GnuPG (GPG)?
By: Darrell Brogdon in Trends Tutorials on 2011-01-24
GnuPG is strictly a command-line utility. There are several GUI wrappers to GPG but the binary is usually required. Since its core purpose is to encrypt and decrypt information, we're first going to have a look at doing just that, using GPG.
As with most Unix-based command-line utilities you first call the gpg command followed by switches that affect the output of the utility. For example, to encrypt a file called "my_secret_data.txt" you would call GnuPG with the -ecommand to encrypt followed by the -r NAME to tell GnuPG who should be able to decrypt the file. "NAME" in this instance is the first name or email address of the person who will be receiving the encrypted file. (Note that the user indicated by NAME must be in your public key ring and can be obtained by typing gpg -list-keys).
Here it is in action:
$ gpg -e -r [email protected] my_secret_file.txt
Once this is done you will a file called 'my_secret_file.txt.gpg' in your current directory. Any attempts to view the contents of this file will prove futile unless you encrypted it using your own Public Key. Feeling like a secret agent yet?
Now suppose Mr. John Doe has encrypted a file and sent it to you. To decrypt it you simply use the -d switch followed by the encrypted file.
$ gpg -d john_doe_secret_file.txt.gpg
Since you have your private key contained within your secret key ring GnuPG can determine whom 'john_doe_secret_file.txt.gpg' was intended for and will decrypt it after you provide your passphrase.
Add Comment
This policy contains information about your privacy. By posting, you are declaring that you understand this policy:
- Your name, rating, website address, town, country, state and comment will be publicly displayed if entered.
- Aside from the data entered into these form fields, other stored data about your comment will include:
- Your IP address (not displayed)
- The time/date of your submission (displayed)
- Your email address will not be shared. It is collected for only two reasons:
- Administrative purposes, should a need to contact you arise.
- To inform you of new comments, should you subscribe to receive notifications.
- A cookie may be set on your computer. This is used to remember your inputs. It will expire by itself.
This policy is subject to change at any time and without notice.
These terms and conditions contain rules about posting comments. By submitting a comment, you are declaring that you agree with these rules:
- Although the administrator will attempt to moderate comments, it is impossible for every comment to have been moderated at any given time.
- You acknowledge that all comments express the views and opinions of the original author and not those of the administrator.
- You agree not to post any material which is knowingly false, obscene, hateful, threatening, harassing or invasive of a person's privacy.
- The administrator has the right to edit, move or remove any comment for any reason and without notice.
Failure to comply with these rules may result in being banned from submitting further comments.
These terms and conditions are subject to change at any time and without notice.
- Data Science
- Android
- React Native
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Related Tutorials
Using OBS Studio to record tutorial videos for YouTube
Will C and C++ be replaced by newer languages?
React vs Angular - How to choose?
What is Groovy? Getting Started with Groovy - A tutorial
Introduction to Amazon Web Services
Browser Based Communications - WebRTC
Will Apple open retail showrooms in India?
Comments