Use Vim under Linux / Vi for file encryption and decryption

This article describes the use under Linux Vim / Vi simple way to encrypt and decrypt the file, Vim's file encryption function is not very strong, but more practical, because you can achieve by means other unwanted software.

First, the use Vim / Vi Encryption:

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:

or

 2) into the edit mode, press enter After the ESC contents, then type: X (uppercase X-note), a carriage return;

Use Vim under Linux / Vi for file encryption and decryption

3) Then the system prompts you to enter the password twice, as follows:

enter password: *******

Please enter it again: *******

Use Vim under Linux / Vi for file encryption and decryption

4) Save and exit, and now this document has been encrypted;

5) or more with a cat view the 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!

Use Vim under Linux / Vi for file encryption and decryption

Use Vim under Linux / Vi for file encryption and decryption

 Note: file encryption, do not forget your password!

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

 :set key=

Then directly enter, save the file, the file has been decrypted.

Use Vim under Linux / Vi for file encryption and decryption

2) or this line also:

After opening the file with the correct ": X" command, and then give a blank password can be. Save with "wq!" Save.

Both methods actually effect is the same.

Guess you like

Origin www.linuxidc.com/Linux/2019-08/159920.htm
Recommended