CentOS uses vim/vi to encrypt and decrypt files. 1. use vim/vi to encrypt files. Advantages: After encryption, if you do not know the password, you cannot see the plaintext, including root users; disadvantages: clearly let others know about encryption, and easily let others destroy encrypted files, including content destruction and deletion. I believe everyone is familiar with vi editor, in vi, there is a command to encrypt the file. for example: 1) First, create an experiment file text.txt: [root @ www ~ under the root directory/root ~
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.