CentOS under Vim text encryption and decryption

CentOS with vim / vi file encryption and decryption

First, the use / vi encryption vim:

Pros: After encryption, if you do not know the password, you can not see clear text, including the root user can not see;
Disadvantages: It is clear to let people know encryption, and easy for others to destroy encrypted file out, including the contents of destruction and deletion;
vi editor I believe we are very familiar with it, vi, there is a command to encrypt the file, give you an example:
1) first create a test file in the root text.txt home directory / root / under:
[root @ ~ the WWW ] # vim / vi named text.txt in the
2) to enter edit mode, enter the complete contents of press ESC, and enter: X (note the capital X), carriage return;
3) then the system prompts you to enter the password twice as follows:
enter password: *******
Please try to enter: *******
4) save and exit, and now this document has been encrypted;
5) with a cat or more to view file contents, garbled; re-edit the file with vim / vi, you will be prompted to enter a password, if the password is entered incorrectly, it will also appear as gibberish!
Note: file encryption, do not forget your password!


Second, to decrypt encrypted files with vi (provided that you know the encrypted password):

1) opened with vim / vi named text.txt in such document, to enter the correct password, and then edit, the password is set to null, the following command is inputted:
: Key = SET
then directly enter, save the file, documents have been declassified.
2) This is also OK, or:
After opening the file with the correct ": X" command, and then to also be a blank password. Save with "wq!" Save.
Both methods actually effect is the same.

Guess you like

Origin www.cnblogs.com/7haoyu/p/11266549.html
Recommended