Text encryption and decryption by Vim in CentOS

Source: Internet
Author: User

Use vim/vi to encrypt and decrypt files in CentOS
1. Use vim/vi encryption:
Advantage: After encryption, if you do not know the password, you will not be able to see the plaintext, including root users;
Disadvantage: it is obvious that encryption is known to others, and encryption files, including content destruction and deletion, are easily destroyed;

I believe everyone is familiar with the vi editor. There is a command in vi that encrypts files. For example:
1) Create an experiment file text.txt under the root directory/root:
[Root @ www ~] # Vim/vi text.txt
2) enter the edit mode, Press ESC after entering the content, and then enter: X (note that it is uppercase X), and press ENTER;
3) The system prompts you to enter the password twice, as shown below:
Enter the password :*******
Enter it again :*******
4) Save and exit. Now the file is encrypted;
5) Use cat or more to view the file content, which is garbled; Use vim/vi to re-edit the file and prompt you to enter the password. If the entered password is incorrect, garbled characters are also displayed!
Note: Do not forget the password after the file is encrypted!
Ii. decrypt files encrypted with vi (provided that you know the encrypted password ):
1) Use vim/vi to open a file such as text.txt. Enter the correct password and set the password to null during editing by entering the following command:
: Set key =
Press enter to save the file. The file has been decrypted.
2) Alternatively, you can:
After opening the file correctly, run the ": X" command and then give a blank password. Save and use "wq !" Save.
The two methods are actually the same.


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.