File encryption operation record under Linux

Source: Internet
Author: User
Tags gnupg gpg

For security reasons, some important files are usually encrypted or encrypted, and the following is a brief introduction to the file encryption method under Linux:

One, zip encryption
1) file encryption
Use the command "zip-e filename.zip filename" To enter the password prompt, enter the password 2 times. This file is encrypted when you need a password to extract

The following begins to encrypt the test.txt file [[email protected] ~]# cat Test.txt this is a test!!! [[email protected] ~]# zip-e test.txt.zip test.txt         //The following encryption operation, you need to enter the password two times enter password:                           Verify password:   Adding:test.txt (stored 0) [[email protected] ~]# lstest.txt test.txt.zip  for decompression, you need to enter the password [[email protected] ~]# rm-f Test.txt[[email protected] ~]# unzip Test.txt.zip Archive:  test.txt.zip[test.txt.zip] test.txt password:  Extracting:test.txt                [[email protected] ~]# cat test.txtthis is a test!!!

2) Folder encryption
Use the command "zip-re dirname.zip dirname" To enter the password prompt, enter the password 2 times. This file is encrypted when the decompression is required password.

 below begins to encrypt the directory [[email protected] ~]# mkdir dirtest[[email protected] ~ ]# Cat Dirtest/haha.txt This is test of DIR!!! [[email protected] ~]# zip-re dirtest.zip dirtestenter password:verify password:adding:dirtest/(stored 0) ad Ding:dirtest/haha.txt (stored 0%) need to enter password when extracting directory [[email protected] ~]# rm-rf dirtest[[email protected] ~]# Unzip Dirtest.zip Archive:dirtest.zip Creating:dirtest/[dirtest.zip] Dirtest/haha.txt password:extracting:dirtest/ Haha.txt [[email protected] ~]# ls dirtesthaha.txt[[email protected] ~]# cat Dirtest/haha.txt This is TES T of dir!!! 

II, GNUPG encryption
GnuPG's full name is GNU Privacy Protection (GNU Privacy Guard), often referred to as GPG, which combines a set of cryptographic software. It was written in the C programming language by the GNU project. The latest stable version is 2.0.27. In most Linux distributions today, the GNUPG package is shipped by default, so in case it isn't installed, you can use apt or yum to install it from the repository (yum install gnupg). Note: GPG can only encrypt the file, and the directory will not complete encryption!

The following begins to encrypt the Test.txt file using the GnuPG method [[email protected] ~]# cat Test.txt this is a test!!!         [[email protected] ~]# gpg-c test.txt can ' t connect to '/root/.gnupg/s.gpg-agent ': No such file or directory This information can be ignored note: As on the encryption, the paraphrase will be asked to enter two password, the specific file encryption. Once you run the GPC command with the-C option (fully encrypted with the symmetric cipher algorithm), it generates a file. gpg file. [[email protected] ~]# ll Test.txt*-rw-r--r--. 1 root root 4 10:08 test.txt-rw-r--r--. 1 root root 4 10:04 test.txt.gpg The file is encrypted, it is best to delete the source file! Don't keep the source files anymore! [[email protected] ~]# rm-f test.txt file decryption operation. Note When the paraphrase prompt appears, you need to provide the same password that you entered when encrypting to decrypt [[email protected] ~]# gpg test.txt.gpg gpg:3des encrypted Datacan ' t Connect to '/root/.gnupg/s.gpg-agent ': No such file or directorygpg:encrypted with 1 passphrasegpg:WARNING:message was Not integrity Protected[[email protected] ~]# ll Test.txt*-rw-r--r--. 1 root root 4 10:08 test.txt-rw-r--r--. 1 root root 4 Jan 10:04 test.txt.gpg[[email protected] ~]# cat test.txtthis is a test!!!

File encryption operation record under Linux

Related Article

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.