Use a password in Linux to encrypt and decrypt files

Source: Internet
Author: User

Use a password in Linux to encrypt and decrypt files

Sometimes, you need to send a file containing sensitive information to someone over the internet, so you start to think, "My file contains some very sensitive information, how can I send files securely and reliably?" There are many ways to send encrypted files. A good way to encrypt a file is to use a long password and combine it with the GPG, that is, the GNU Privacy Guard (GnuPG or GPG) tool. Once you encrypt the file, you can perform several operations.

1. Put the file on an FTP or Web server that requires another set of usernames and passwords.

2. To further ensure security, you can set firewall rules to allow only one IP Address/network to access this location.

3. Send the file via email as an attachment.

4. Send the file through an encrypted email (double encryption ). We will soon discuss email encryption.

5. If the file to be sent is too large (such as a video or a large file), create a torrent file and send it in private torrent format.

Therefore, there are countless examples. GnuPG or GPG can be used on Windows, Linux, Mac (any iOS device), Android, BlackBerry, and other platforms. In short, GnuPG or GPG is supported on all platforms, making it an excellent encryption tool.

GNU Privacy Guard (GnuPG or GPG)

The reason why GnuPG is a hybrid encryption software program is that it uses the traditional symmetric key cryptography algorithm (to ensure high speed) and public key cryptography algorithm (to ensure easy and secure key exchange ), the implementation method is usually to use the receiver's public key to encrypt the session key only once. This operation mode is part of the OpenPGP standard and part of PGP since the first version.

GnuPG uses an asymmetric key pair separately created by the GnuPG user to encrypt messages. The generated public key can be exchanged with other users in many ways, such as the Internet Key Server. The public key must be carefully exchanged to prevent identity fraud caused by the identity communication of the public key "owner. It is also possible to add a digital signature for the message to verify the message integrity and sender.

Download GnuPG

You can download GnuPG for the following operating systems.

WindowsOS XDebianRPM Android VMS (OpenVMS) Proteus OS * BSD * NIXAIXHPUXIRIXSolaris, SunOS

The GnuPG supported operating system list (https://www.gnupg.org/download/supported_systems.html) provides a comprehensive list of supported operating systems.

In addition to these operating systems, most operating systems implement GnuPG in their own way and support each other because underlying encryption and decryption work in a similar way.

Encrypted Files in Linux

To encrypt a single file, run the gpg command as follows:

root@kali:~# gpg -c secretfilename

To add the secret secretfilename.txt file, enter the following command:

root@kali:~# gpg -c secretfilename.txt

Sample output:

Enter passphrase:Repeat passphrase:

This will create the secretfilename.txt. gpg file. The GnuPG or GPG help documentation is as follows:

GnuPG or GPG help menu

If you forget the password (password phrase), you cannot recover the data because it uses a very strong encryption mechanism.

Decrypt a file

To decrypt a file, run the gpg command as follows:

root@kali:~# gpg secretfilename.txt.gpg

Sample output:

gpg secretfilename.txt.gpggpg: CAST5 encrypted dataEnter passphrase:

If you want to decrypt the file and write the output to the file secretfilename.txt, you can run the following command:

root@kali:~# gpg secretfilename.txt.gpg –o secretfilename.txt

Conclusion

As you can see, GnuPG does have its actual purpose; in many cases, it is used for both joint activities and illegal activities. I will not discuss the validity of using GnuPG, but if you really need to send and transmit the files to be encrypted, GnuPG or GPG is definitely a tool worth considering, files can be encrypted on Linux, Unix, Windows, or any common platform.

Address: http://www.blackmoreops.com/2015/05/07/encrypting-files-with-password/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.